Skip to content

Syntax highlighting breaks when trying to Show whitespace and tab characters for C/C++ files (v3.3.1+) #234

@nehalsharmap4

Description

@nehalsharmap4

Summary
When enabling the “Show whitespace and tab characters” option, syntax highlighting stops working correctly for .c and .cc files.
This issue starts appearing in v3.3.1 and persists in higher versions. It works fine in v2.4.1.

Steps to Reproduce

  1. Use react-diff-view v3.3.1 or later
  2. Load a diff containing .c or .cc files.
  3. Enable Show whitespace and tab characters.
  4. Observe that syntax highlighting disappears or becomes inconsistent.

Expected Behavior
Syntax highlighting should remain functional even when whitespace and tab characters are shown.

Actual Behavior
When the whitespace view is enabled, the new tokenization merges whitespace into syntax tokens, breaking syntax highlighting for .c and .cc files.

Notes

  • Not reproducible in v2.4.1.
  • The regression is likely related to the new tokenization system introduced in v3.3.1.
  • Simpler file types (like .js, .py) are unaffected.
  • Consistently reproducible on Chrome (latest).

Environment

  • react-diff-view: v3.3.1 and above
  • Browser: Chrome (latest)
  • Affected file types: .c, .cc
  • OS: macOS / Windows

Suggested Action
Review the whitespace tokenization logic introduced in v3.3.1.
Consider separating whitespace visualization from syntax token merging to restore proper highlighting for C/C++ grammars.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions