Skip to content

Suppress unified diff when token comparators ignore all changes - #2936

Open
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/token-comparator-suppresses-unified-diff
Open

tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/token-comparator-suppresses-unified-diff

Conversation

@tobiasmelcher

@tobiasmelcher tobiasmelcher commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

The unified diff feature uses two levels of comparison: a line-level diff
to find changed regions, and a token-level diff (via ITokenComparator) to
highlight the exact words that changed within each region.

A custom ITokenComparator can normalise text before comparing — for example
treating "line ONE" and "line one" as equal. In that case the line-level
diff reports a change, but the token diff finds nothing: all results are
NOCHANGE. Before this fix, the parent UnifiedDiff was created and shown to
the user anyway, producing a highlighted region with no inline delta. The
annotation was visually present but carried no information, which was
confusing.

The fix moves the token diff computation ahead of the UnifiedDiff
construction. If hasDetailedChanges() returns false the change is skipped
entirely, so only diffs with at least one real token difference are ever
presented to the user.

Helped by Claude Code (Anthropic).

If line-level diffing detects a change but the token comparators report
no actual differences (e.g. a case-insensitive comparator on identical
text), no parent diff is added to the list. Previously a unified diff
was shown to the user without any detailed delta, which was confusing.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   57m 8s ⏱️ - 2m 26s
 4 811 tests +1   4 789 ✅ +1   22 💤 ±0  0 ❌ ±0 
12 324 runs  +3  12 171 ✅ +3  153 💤 ±0  0 ❌ ±0 

Results for commit 04c75e8. ± Comparison against base commit 2d15cf3.

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