Repository navigation
Poor diff highlight contrast in Dark Theme (Compare editor and Unified Diff) #2993
Description
Problem
Users reported that in Eclipse Dark Theme, the changed-line highlight colors in the Compare editor have very poor contrast: the red/green diff backgrounds are barely distinguishable from the near-black editor background. Other tools (e.g. VS Code) achieve noticeably better contrast for the same type of diff.
The problem affects both:
- The 2-way Compare editor (
TextMergeViewer) - The Unified Diff view (inline code mining annotations)
Root Cause
The default base colors are defined in plugin.xml (lines 82–108):
DELETION_COLOR=COLOR_RED(#FF0000)ADDITION_COLOR=COLOR_DARK_GREEN(#008000)
These are then blended 90% toward the editor background by TextMergeViewer.ColorPalette:
normal = interpolate(selected, background, 0.6);
fill = interpolate(selected, background, 0.9); // used for line background
textFill = interpolate(selected, background, 0.8);On a dark background (~#1E1E1E), a 90% blend of dark green/pure red toward black produces a color barely distinguishable from the background. The same logic applies in UnifiedDiffCodeMiningProvider (interpolation at 0.9/0.8).
Existing Partial Fix
dark.css (team/bundles/org.eclipse.compare/resources/css/dark.css) already overrides the unified diff annotation colors for the dark theme:
IEclipsePreferences#org-eclipse-ui-editors:org-eclipse-compare {
preferences:
'inlineDiffColor=27,40,30'
'detailedInlineDiffColor=24,50,27'
'deletionInlineDiffColor=52,27,30'
'detailedDeletionInlineDiffColor=74,24,27'
}However:
- These values are still very dark — the colors are slightly less wrong but still low-contrast.
- The 2-way Compare side (
ADDITION_COLOR/DELETION_COLORin the JFace color registry, consumed byTextMergeViewer) has no dark theme override at all.
Light-Theme Defaults (for reference)
| Annotation | Light RGB | Preference key |
|---|---|---|
| Addition line bg | 229,242,229 |
inlineDiffColor |
| Deletion line bg | 255,229,229 |
deletionInlineDiffColor |
| Word-level addition | 204,229,204 |
detailedInlineDiffColor |
| Word-level deletion | 255,204,204 |
detailedDeletionInlineDiffColor |
Affected Files
| File | Role |
|---|---|
team/bundles/org.eclipse.compare/plugin.xml L82–108 |
DELETION_COLOR=COLOR_RED, ADDITION_COLOR=COLOR_DARK_GREEN |
team/bundles/org.eclipse.compare/resources/css/dark.css |
Dark theme overrides (annotation colors only, values too dark) |
team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java:353 |
ColorPalette — interpolates 60/80/90% toward background |
team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/UnifiedDiffCodeMiningProvider.java:151 |
Same interpolation for unified diff |
Proposed Fix
dark.css: Raise the brightness of the 4 annotation color values so they are visible on dark backgrounds (e.g.60,90,60/100,50,55instead of27,40,30/52,27,30).plugin.xml: Add dark-theme overrides forADDITION_COLORandDELETION_COLOR(viathemeElementOverrideor by adjusting defaults) so thatTextMergeViewer's interpolation produces a visible result on dark backgrounds.
Activity
tobiasmelcher commentedon Oct 5, 2026
Screenshot showing the issue in Eclipse Dark Theme (the diff highlight is barely visible on the dark background):
jasmin261098 commentedon Oct 5, 2026
I compared some contrasts and let claude create an overview of colors that could be used for better visibility in dark mode.
Three options to choose from, hexcodes can be found in the picture. If rgb numbers are needed the codes can be converted.
Personally I would choose option C, but option B is more fitting for the look of dark mode.
Correction:
Considering the interpolate method, option C is not feasible. So we can only achive this improvement:
tobiasmelcher commentedon Oct 5, 2026
Implementation note: The diff colors in both the 2-way compare (
TextMergeViewer) and unified diff (UnifiedDiffCodeMiningProvider) are derived from the user-configurableADDITION_COLOR/DELETION_COLORpreferences via an interpolation toward the editor background. The interpolation scale (0.9 for fill, 0.8 for detail) produces acceptable results in light theme but washes out any color in dark theme — it is mathematically impossible to reach a well-contrasted result by changing the base color alone at those scales.The chosen fix is to keep the existing user-configurable color architecture unchanged and instead reduce the interpolation scale factors when the dark theme is active (fill: 0.79, detail: 0.67). Dark theme is detected via the luminance of
INFORMATION_BACKGROUND_COLORfrom the theme registry. This produces colors close to Option C from the color comparison above.