Skip to content

Add dedicated overview-ruler annotation types for unified diff - #3004

Open
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/unified-diff-ruler-annotations
Open

tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/unified-diff-ruler-annotations

Conversation

@tobiasmelcher

@tobiasmelcher tobiasmelcher commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2941

What

Adds overview-ruler markers for top-level unified-diff hunks. Until now the
unified diff presentation highlighted differences only in the visible editor
area and showed nothing on the overview ruler, so off-screen differences were
hard to discover and navigate.

This is done by introducing two dedicated overview-ruler annotation types:

  • org.eclipse.compare.unifieddiff.internal.addition.ruler
  • org.eclipse.compare.unifieddiff.internal.deletion.ruler

They paint only on the overview ruler, with saturated, high-contrast
colors (40,140,40 green and 220,50,50 red) and a sharp 1px border. Each
ruler annotation also carries a human-readable tooltip ("Addition at line N",
"Deletion from line M to N") shown when hovering a ruler tick. The existing
addition / deletion types continue to paint the pastel text highlight in
the editor and are untouched. Detailed/token-level diff annotations
(detailedAddition, detailedDeletion) deliberately produce no ruler
markers.

Why two new types instead of reusing the existing annotations

In Eclipse, an annotation type declared in markerAnnotationSpecification
uses a single colorPreferenceValue for both the editor text highlight
(drawn by AnnotationPainter) and the overview ruler (drawn by
OverviewRuler).

  • For the text highlight to stay readable behind source code, the diff colors
    must be light pastels (229,242,229 for additions, 255,229,229 for
    deletions).
  • OverviewRuler computes its fill by fading the color 75% towards the
    background, and its 1px border by fading it 20% towards the background. With
    those pastels, both the fill and the border become virtually invisible on
    the ruler.
  • Overriding the ruler globally with setUseSaturatedColors(true) is not an
    option: it is global and would ruin the saturation of every other annotation
    in the editor (warnings, search results, bookmarks, etc.).

Dedicated ruler-only annotation types let each side use the color it needs:
pastel for a readable in-text highlight, saturated for a clearly visible ruler
tick, without touching any other annotation in the workbench.

Notes

  • The unused symbolicIcon="info" is dropped from the four pre-existing
    inline-diff specs. The icon was never shown because all four set
    verticalRulerPreferenceValue and contributesToHeader to false.
  • No dark-theme color override is set for the new ruler types, by intention.
    The standard error and warning overview-ruler annotations also set no
    dark-theme override in org.eclipse.ui.themes — they use their
    colorPreferenceValue defaults unchanged in both themes. The new
    addition.ruler / deletion.ruler types follow the same convention for
    symmetry.

This change was prepared with the help of Claude Code.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

    51 files  ± 0      51 suites  ±0   58m 6s ⏱️ +45s
 4 480 tests + 4   4 457 ✅ + 3   22 💤 ±0  1 ❌ +1 
11 529 runs  +12  11 374 ✅ +11  154 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 20e5e87. ± Comparison against base commit 8b229d0.

♻️ This comment has been updated with latest results.

@tobiasmelcher
tobiasmelcher requested a review from vogella October 9, 2026 11:30
Eclipse annotation types declared in markerAnnotationSpecification share a
single colorPreferenceValue for both the editor text highlight (drawn by
AnnotationPainter) and the overview ruler (drawn by OverviewRuler). The
unified-diff highlights must stay light pastels (229,242,229 for additions,
255,229,229 for deletions) so they remain readable behind source code. The
OverviewRuler fades every color 75% towards the background for its fill and
20% for its 1px border, so with those pastels both the fill and the border
become virtually invisible on the ruler. Calling setUseSaturatedColors(true)
is not an option: it is global and would ruin the saturation of every other
annotation in the editor (warnings, search results, bookmarks, etc.).

Decouple the editor text highlight from the overview ruler by introducing two
dedicated ruler-only annotation types, addition.ruler and deletion.ruler. The
existing addition/deletion types keep painting the pastel text highlight and
no longer paint on the ruler; the new types carry saturated, high-contrast
colors (40,140,40 and 220,50,50) and paint only in the overview ruler. They
also carry the tooltip text ("Addition at line N", "Deletion from line M to
N") so hovering a ruler tick shows a human-readable description. The detailed
diff types (detailedAddition, detailedDeletion) are left unchanged.

Also drop the unused symbolicIcon="info" from the four pre-existing inline
diff specs. The icon was never shown because all four set
verticalRulerPreferenceValue and contributesToHeader to false.
@tobiasmelcher
tobiasmelcher force-pushed the d031119/unified-diff-ruler-annotations branch from c662b0a to 20e5e87 Compare October 9, 2026 14:49
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.

Unified Diff: Add overview ruler markers for diff hunks

1 participant