diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java index e63b1b5162c..8ef74c588d4 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java @@ -26,6 +26,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; @@ -468,6 +469,25 @@ protected void createControl(Composite parent, int styles) { if (fOverviewRuler != null) { fOverviewRuler.createControl(fComposite, this); } + + if (fComposite != null) { + StyledText textWidget= getTextWidget(); + if (textWidget != null) { + // Match the canvas background to the text widget so the RulerLayout gap blends in. + syncCompositeBackground(textWidget); + textWidget.addPaintListener(e -> syncCompositeBackground(textWidget)); + } + } + } + + private void syncCompositeBackground(StyledText textWidget) { + if (fComposite == null || fComposite.isDisposed() || textWidget.isDisposed()) { + return; + } + Color desired= textWidget.getBackground(); + if (desired != null && !desired.equals(fComposite.getBackground())) { + fComposite.setBackground(desired); + } } /**