Skip to content

fix(diff): use full-file context to highlight diff hunks#342

Merged
jennings merged 1 commit into
mainfrom
jennings/umonqypxornt
Jul 9, 2026
Merged

fix(diff): use full-file context to highlight diff hunks#342
jennings merged 1 commit into
mainfrom
jennings/umonqypxornt

Conversation

@jennings

@jennings jennings commented Jul 9, 2026

Copy link
Copy Markdown
Owner

parseDiffWithHighlighting accepted oldContent/newContent (which useDiffLoader was already fetching and passing through) but ignored them, highlighting only the hunk fragment. When a hunk starts after a closing raw string like "#);, Refractor's Rust grammar sees the fragment's leading " as an opening string and cascades the rest of the file: comments get tagged as string content and string contents get tagged as code.

Pre-highlight each side's full file once when contents are provided and look up each hunk line's HTML by its line number. Fall back to the previous per-hunk block highlighting when contents aren't provided.

Adds a regression test that feeds a hunk beginning with a raw-string terminator and asserts the surrounding comment tags as token comment rather than token string.

parseDiffWithHighlighting accepted oldContent/newContent (which
useDiffLoader was already fetching and passing through) but ignored
them, highlighting only the hunk fragment. When a hunk starts after
a closing raw string like `"#);`, Refractor's Rust grammar sees the
fragment's leading `"` as an opening string and cascades the rest of
the file: comments get tagged as string content and string contents
get tagged as code.

Pre-highlight each side's full file once when contents are provided
and look up each hunk line's HTML by its line number. Fall back to
the previous per-hunk block highlighting when contents aren't
provided.

Adds a regression test that feeds a hunk beginning with a raw-string
terminator and asserts the surrounding comment tags as token comment
rather than token string.
@jennings jennings enabled auto-merge (rebase) July 9, 2026 07:02
@jennings jennings marked this pull request as draft July 9, 2026 07:26
auto-merge was automatically disabled July 9, 2026 07:26

Pull request was converted to draft

@jennings jennings marked this pull request as ready for review July 9, 2026 07:26
@jennings jennings enabled auto-merge (rebase) July 9, 2026 07:55
@jennings jennings merged commit 5bd6594 into main Jul 9, 2026
4 of 8 checks passed
@jennings jennings deleted the jennings/umonqypxornt branch July 9, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant