From e543eeedf1af507ac466240253802c923c2837ed Mon Sep 17 00:00:00 2001 From: Maximilian Wittmer Date: Mon, 10 Jun 2024 11:05:01 +0200 Subject: [PATCH] Find/Replace overlay: handle the case when moving editor between windows When moving the targeted editor between different windows, the overlay is closed to allow a retargetting. fixes #1945 --- .../org/eclipse/ui/texteditor/FindReplaceAction.java | 2 +- .../org/eclipse/ui/texteditor/FindReplaceOverlay.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java index e253c0902b4..6d6eb23dbc8 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java @@ -411,7 +411,7 @@ private void showDialog() { } private void showOverlayInEditor() { - if (overlay == null) { + if (overlay == null || !overlay.isOverlayOpen()) { Shell shellToUse = null; if (fShell == null) { diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceOverlay.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceOverlay.java index 5f465d90b56..04009984842 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceOverlay.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceOverlay.java @@ -309,6 +309,9 @@ public boolean close() { @Override public int open() { + if (!okayToUse(getShell())) { + return Window.CANCEL; + } int returnCode = Window.OK; if (!overlayOpen) { returnCode = super.open(); @@ -763,6 +766,10 @@ private void repositionTextSelection() { } private void positionToPart() { + if (getShell() == null || !targetPart.getSite().getShell().equals(getShell().getParent())) { + close(); + return; + } getShell().requestLayout(); if (!(targetPart instanceof StatusTextEditor)) { return; @@ -863,4 +870,8 @@ private static boolean okayToUse(Widget widget) { public void setPositionToTop(boolean shouldPositionOverlayOnTop) { positionAtTop = shouldPositionOverlayOnTop; } + + public boolean isOverlayOpen() { + return overlayOpen; + } } \ No newline at end of file