[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:

  1. 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.
  2. Canonical Extensionless Files: Files such as Dockerfile, Makefile, Gemfile, Rakefile, CMakeLists.txt, .bashrc, .gitignore have no file extension, so standard extension lookup yields no language.
  3. 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.
  4. Git Rename Notations: Diffs with rename formats (old.ts -> new.ts or 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 by CodeProps in mods/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:

  1. sanitizePath (mods/diff/hooks/views/layout/sanitize-path/): Normalizes Windows backslashes, git renames, and control chars.
  2. 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.
  3. <Code> integration in detail-view.tsx and draw-window.tsx passing both path and language.
  4. Unit tests in sanitize-path.test.ts, language-of.test.ts, and updated detail-view.test.ts.
  5. 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)

View original on GitHub ↗