Skip to content

fix: scope unified diff comment highlight to commented side#479

Merged
tomasz-tomczyk merged 3 commits intomainfrom
fix-unified-comment-visual-range
May 7, 2026
Merged

fix: scope unified diff comment highlight to commented side#479
tomasz-tomczyk merged 3 commits intomainfrom
fix-unified-comment-visual-range

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • Comments anchored to a single line in the unified-diff view were highlighting every line up through the comment, including unrelated deletions earlier in the same hunk, when an unrelated line on the opposite side happened to share the commented line number.
  • buildUnifiedCommentVisualSet now anchors strictly to the comment's side: new-side comments only match add/context lines by NewNum; old-side only match del/context by OldNum. Lines between the anchored start/end stay highlighted regardless of type, so genuine multi-line ranges spanning deletions still work.

Review

  • Code review: passed (frontend-expert fresh pass, 0 blockers)
  • Parity audit: N/A — crit-web/assets/js/document-renderer.js has no equivalent unified code-diff renderer

Test plan

  • New e2e/tests/unified-comment-visual-range.spec.ts regression 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 ./... passes
  • mise exec -- golangci-lint run ./... clean
  • Existing comment-range-highlight.spec.ts (7 tests) still passes

🤖 Generated with Claude Code

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
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.10%. Comparing base (af76394) to head (7d94823).
⚠️ Report is 1 commits behind head on main.

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     
Flag Coverage Δ
e2e 32.41% <ø> (+0.05%) ⬆️
unit 66.94% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

tomasz-tomczyk and others added 2 commits May 7, 2026 11:25
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk merged commit 6781ad5 into main May 7, 2026
8 of 10 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix-unified-comment-visual-range branch May 7, 2026 11:17
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