From aaec895eff90785afd736608454bb9b0621f8bff Mon Sep 17 00:00:00 2001
From: Heiko Klare <heiko.klare@vector.com>
Date: Tue, 16 Jul 2024 21:17:54 +0200
Subject: [PATCH] Find/replace overlay: reassign to changed shell
 asynchronously #1945

The synchronous execution of reassigning the FindReplaceOverlay to a
shell sporadically makes the application hang on Linux. This makes the
execution asynchronous and avoid repeated executions of the
reassignment.

Contributes to
https://github.com/eclipse-platform/eclipse.platform.ui/issues/1945
---
 .../findandreplace/overlay/FindReplaceOverlay.java   | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

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 135e8e67e48..2f37b7be234 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
@@ -883,11 +883,13 @@ private void updatePlacementAndVisibility() {
 			return;
 		}
 		if (isInvalidTargetShell()) {
-			getShell().getDisplay().syncExec(() -> {
-				close();
-				setParentShell(targetPart.getSite().getShell());
-				open();
-				targetPart.setFocus();
+			getShell().getDisplay().asyncExec(() -> {
+				if (isInvalidTargetShell()) {
+					close();
+					setParentShell(targetPart.getSite().getShell());
+					open();
+					targetPart.setFocus();
+				}
 			});
 			return;
 		}