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 69eff374af2..f7391b1c5b9 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 @@ -195,19 +195,24 @@ private void performSelectAll() { private ControlListener shellMovementListener = new ControlListener() { @Override public void controlMoved(ControlEvent e) { - if (getShell() != null) { - getShell().getDisplay().asyncExec(() -> updatePlacementAndVisibility()); - } + asyncUpdatePlacementAndVisibility(); } @Override public void controlResized(ControlEvent e) { - if (getShell() != null) { - getShell().getDisplay().asyncExec(() -> updatePlacementAndVisibility()); - } + asyncUpdatePlacementAndVisibility(); } }; + private PaintListener widgetMovementListener = __ -> asyncUpdatePlacementAndVisibility(); + + private void asyncUpdatePlacementAndVisibility() { + Shell shell = getShell(); + if (shell != null) { + shell.getDisplay().asyncExec(this::updatePlacementAndVisibility); + } + } + private ShellAdapter overlayDeactivationListener = new ShellAdapter() { @Override public void shellActivated(ShellEvent e) { @@ -220,8 +225,6 @@ public void shellDeactivated(ShellEvent e) { } }; - private PaintListener widgetMovementListener = __ -> updatePlacementAndVisibility(); - private static class TargetPartVisibilityHandler implements IPartListener2, IPageChangedListener { private final IWorkbenchPart targetPart; private final IWorkbenchPart topLevelPart; @@ -926,11 +929,16 @@ private void updatePosition(Rectangle overlayBounds) { } private void updateVisibility(Rectangle targetControlBounds, Rectangle overlayBounds) { + boolean shallBeVisible = true; if (positionAtTop) { - getShell().setVisible( - overlayBounds.y + overlayBounds.height <= targetControlBounds.y + targetControlBounds.height); + shallBeVisible = overlayBounds.y + overlayBounds.height <= targetControlBounds.y + + targetControlBounds.height; } else { - getShell().setVisible(overlayBounds.y >= targetControlBounds.y); + shallBeVisible = overlayBounds.y >= targetControlBounds.y; + } + Shell shell = getShell(); + if (shallBeVisible != shell.isVisible()) { + shell.setVisible(shallBeVisible); } }