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 b7d737c403a..2af0bf0ffe1 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 @@ -303,6 +303,11 @@ private void focusTargetWidget() { targetWidget.forceFocus(); } }; + private KeyListener closeOnEditorEscapeListener = KeyListener.keyPressedAdapter(c -> { + if (c.keyCode == SWT.ESC) { + this.close(); + } + }); private boolean isPartCurrentlyDisplayedInPartSash() { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); @@ -410,6 +415,7 @@ private void unbindListeners() { if (targetWidget != null) { targetWidget.getShell().removeControlListener(shellMovementListener); targetWidget.removePaintListener(widgetMovementListener); + targetWidget.removeKeyListener(closeOnEditorEscapeListener); targetPart.getSite().getPage().removePartListener(partListener); } } @@ -422,6 +428,7 @@ private void bindListeners() { targetWidget.getShell().addControlListener(shellMovementListener); targetWidget.addPaintListener(widgetMovementListener); + targetWidget.addKeyListener(closeOnEditorEscapeListener); targetPart.getSite().getPage().addPartListener(partListener); } }