fix: scope unified diff comment highlight to commented side#479
Merged
tomasz-tomczyk merged 3 commits intomainfrom May 7, 2026
Merged
fix: scope unified diff comment highlight to commented side#479tomasz-tomczyk merged 3 commits intomainfrom
tomasz-tomczyk merged 3 commits intomainfrom
Conversation
buildUnifiedCommentVisualSet matched start_line against either OldNum or NewNum, so a comment on a new-side context line below a long deletion block could anchor on a del line earlier in the hunk that happened to share its old-side number. The visible range then engulfed the entire del+add run between them. Anchor strictly to the comment's side: new-side comments only match add/context lines (by NewNum); old-side comments only match del/context lines (by OldNum). Lines between the anchored start/end are still highlighted regardless of type, so multi-line ranges that span deletions continue to highlight those deletions. Adds an E2E regression that builds a hunk where oldNum 13 (a deletion) collides with newNum 13 (a context line below the additions) and asserts a single-line comment on new-side line 13 highlights only the context line.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #479 +/- ##
===========================================
+ Coverage 32.35% 69.10% +36.74%
===========================================
Files 35 43 +8
Lines 10616 10733 +117
===========================================
+ Hits 3435 7417 +3982
+ Misses 6689 2756 -3933
- Partials 492 560 +68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildUnifiedCommentVisualSetnow anchors strictly to the comment's side: new-side comments only matchadd/contextlines byNewNum; old-side only matchdel/contextbyOldNum. Lines between the anchored start/end stay highlighted regardless of type, so genuine multi-line ranges spanning deletions still work.Review
crit-web/assets/js/document-renderer.jshas no equivalent unified code-diff rendererTest plan
e2e/tests/unified-comment-visual-range.spec.tsregression test reproduces the bug (old-vs-new line-number collision in a long deletion hunk); fails on old code (13 highlighted lines), passes on new (1).mise exec -- go test -race ./...passesmise exec -- golangci-lint run ./...cleancomment-range-highlight.spec.ts(7 tests) still passes🤖 Generated with Claude Code