diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java index d9f8cda37f6..54565b57be9 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java @@ -466,11 +466,17 @@ private void initializeSearchShortcutHandlers() { * grab it's color and then immediately dispose of that bar. */ private void retrieveBackgroundColor() { - Text textBarForRetrievingTheRightColor = new Text(container, SWT.SINGLE | SWT.SEARCH); - container.layout(); - backgroundToUse = textBarForRetrievingTheRightColor.getBackground(); - normalTextForegroundColor = textBarForRetrievingTheRightColor.getForeground(); - textBarForRetrievingTheRightColor.dispose(); + if (targetPart instanceof StatusTextEditor textEditor) { + Control targetWidget = textEditor.getAdapter(ITextViewer.class).getTextWidget(); + backgroundToUse = targetWidget.getBackground(); + normalTextForegroundColor = targetWidget.getForeground(); + } else { + Text textBarForRetrievingTheRightColor = new Text(container, SWT.SINGLE | SWT.SEARCH); + container.layout(); + backgroundToUse = textBarForRetrievingTheRightColor.getBackground(); + normalTextForegroundColor = textBarForRetrievingTheRightColor.getForeground(); + textBarForRetrievingTheRightColor.dispose(); + } }