[BUG] Missing syntax highlighting in /diff on Windows and extensionless files (with fix)
Status Open
Reported on v2.1.263
Maintainer reply None cached
Activity 0 comments · opened Sep 14, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In mods/diff, the <Code> component relies solely on the engine inferring the syntax highlighting language from path (<Code source={source} format="diff" path={path} />). This causes syntax highlighting in diff views to fail or render as plain text in several common scenarios:
- Windows Paths: On Windows, file paths passed with backslashes (
\) are not parsed correctly by POSIX-based extension extractors in the engine, resulting in missing syntax highlighting for hunks. - Canonical Extensionless Files: Files such as
Dockerfile,Makefile,Gemfile,Rakefile,CMakeLists.txt,.bashrc,.gitignorehave no file extension, so standard extension lookup yields no language. - Shebang Scripts: Scripts without extensions containing a Shebang (e.g.,
#!/usr/bin/env python3,#!/usr/bin/env node,#!/bin/bash) are not inspected for language hints. - Git Rename Notations: Diffs with rename formats (
old.ts -> new.tsor diff-stat{old => new}) pass raw rename strings as paths, breaking extension inference.
What Should Happen?
- Paths should be normalized across platforms (
\converted to/, invisible/control characters stripped, and rename targets extracted). - The mod should resolve canonical language aliases and pass explicit
language={language}to<Code>(supported byCodePropsinmods/types/claude-code.d.ts).
Ready-made Fix & Unit Tests
I have implemented and verified a clean fix with full unit tests in my fork:
- Commit: fabiooliveir/claude-code@4fb5f0a
- Changes include:
sanitizePath(mods/diff/hooks/views/layout/sanitize-path/): Normalizes Windows backslashes, git renames, and control chars.languageOf(mods/diff/hooks/views/detail/language-of/): Resolves language aliases for common extensions, compound extensions (.d.ts), canonical filenames (Dockerfile,Makefile, etc.), and shebangs.<Code>integration indetail-view.tsxanddraw-window.tsxpassing bothpathandlanguage.- Unit tests in
sanitize-path.test.ts,language-of.test.ts, and updateddetail-view.test.ts. - Typecheck passes cleanly:
tsc -p mods/tsconfig.json --noEmit(0 errors).
Feel free to cherry-pick this commit or adapt it as needed!
Claude Code Version
2.1.263
Platform
Windows (PowerShell / Windows Terminal)