From 6d57b4b513c14e887f62d0b49e6895defe63202c Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Fri, 1 Nov 2024 19:27:48 +0100 Subject: [PATCH] FindReplaceOverlay: avoid inconsistent borders #2194 When the replace toggle in the FindReplaceOverlay is not shown because the target file is read-only or because the editor is too small to show the toggle button, the right border of the overlay is larger than the others. The reason is an inconsistent layout, as the container always expects two columns of elements but when the replace toggle is hidden only one column is present. With this change, the number of columns of the container is adapted according to whether the replace toggle is present or not. Fixed https://github.com/eclipse-platform/eclipse.platform.ui/issues/2194 --- .../findandreplace/overlay/FindReplaceOverlay.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 4472e94a6ec..9b02ac7a3c6 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 @@ -33,6 +33,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -695,9 +696,10 @@ private void enableReplaceToggle(boolean enable) { if (!okayToUse(replaceToggle)) { return; } - boolean visible = enable && findReplaceLogic.getTarget().isEditable(); - ((GridData) replaceToggleTools.getLayoutData()).exclude = !visible; - replaceToggleTools.setVisible(visible); + boolean shouldBeVisible = enable && findReplaceLogic.getTarget().isEditable(); + ((GridLayout) containerControl.getLayout()).numColumns = shouldBeVisible ? 2 : 1; + ((GridData) replaceToggleTools.getLayoutData()).exclude = !shouldBeVisible; + replaceToggleTools.setVisible(shouldBeVisible); } private void enableReplaceTools(boolean enable) {