Skip to content

Fix detailed-diff highlight clipping at end of trimmed diff string - #2965

Open
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/fix-detailed-diff-highlight-clipping
Open

tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/fix-detailed-diff-highlight-clipping

Conversation

@tobiasmelcher

Copy link
Copy Markdown
Contributor

When a detailed diff ended exactly at the last character of the trimmed diff string (start + length == trimmedLength), the old >= guard reduced the highlight length by the number of stripped trailing newlines, cutting off that many characters from the highlight rectangle. The condition is now >, so the length is only clamped when the range actually overshoots.

The same bug existed independently in computeDetailedDiffRanges and createDetailedDiffBackgroundRanges; both now delegate to a shared helper clampDetailedDiffLength in UnifiedDiffText.

Additionally, in getPositionForOffset a newline at the very start of a style range (lfIdx == 0) was ignored, so the x offset was not reset and the following text was mispositioned. The guard is now lfIdx >= 0.

Reviewed with the help of Claude Code.

When a detailed diff ended exactly at the last character of the
trimmed diff string (i.e. start + length == trimmedLength), the
old >= guard incorrectly reduced the length by the number of
stripped trailing newlines, cutting off that many characters from
the highlight rectangle. The fix changes the condition to > so
the length is only clamped when the range actually overshoots.

The same bug existed independently in computeDetailedDiffRanges
and createDetailedDiffBackgroundRanges; both now delegate to a
shared helper clampDetailedDiffLength in UnifiedDiffText.
@tobiasmelcher

Copy link
Copy Markdown
Contributor Author
diff-highlight-clipping

Screenshot from ABAP Development Tools in Eclipse showing the defect: on the added "percentWarning": 1.2, line the green highlight is clipped and stops short of the line end, instead of covering the full changed text like the other added lines.

@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ± 0      54 suites  ±0   59m 15s ⏱️ + 2m 26s
 4 828 tests + 5   4 806 ✅ + 5   22 💤 ±0  0 ❌ ±0 
12 375 runs  +15  12 222 ✅ +15  153 💤 ±0  0 ❌ ±0 

Results for commit 0cd742c. ± Comparison against base commit a439595.

♻️ This comment has been updated with latest results.

@BeckerWdf

Copy link
Copy Markdown
Member

Screenshot from ABAP Development Tools in Eclipse showing the defect: on the added "percentWarning": 1.2, line the green highlight is clipped and stops short of the line end, instead of covering the full changed text like the other added lines.

so the marked boxes should be more left and be the background of the "1.2" text.

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.

2 participants