Skip to content

Commit 742846b

Browse files
Maximilian WittmerHeikoKlare
authored andcommitted
Find/Replace Overlay: close when escape is pressed in the editor
When escape is pressed inside of the editor which is targeted by the find/replace overlay, the overlay now closes. fixes #2033
1 parent e786511 commit 742846b

File tree

1 file changed

+7
-0
lines changed
  • bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay

1 file changed

+7
-0
lines changed

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ private void focusTargetWidget() {
302302
targetWidget.forceFocus();
303303
}
304304
};
305+
private KeyListener closeOnTargetEscapeListener = KeyListener.keyPressedAdapter(c -> {
306+
if (c.keyCode == SWT.ESC) {
307+
this.close();
308+
}
309+
});
305310

306311
private boolean isPartCurrentlyDisplayedInPartSash() {
307312
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
@@ -409,6 +414,7 @@ private void unbindListeners() {
409414
if (targetWidget != null) {
410415
targetWidget.getShell().removeControlListener(shellMovementListener);
411416
targetWidget.removePaintListener(widgetMovementListener);
417+
targetWidget.removeKeyListener(closeOnTargetEscapeListener);
412418
targetPart.getSite().getPage().removePartListener(partListener);
413419
}
414420
}
@@ -421,6 +427,7 @@ private void bindListeners() {
421427

422428
targetWidget.getShell().addControlListener(shellMovementListener);
423429
targetWidget.addPaintListener(widgetMovementListener);
430+
targetWidget.addKeyListener(closeOnTargetEscapeListener);
424431
targetPart.getSite().getPage().addPartListener(partListener);
425432
}
426433
}

0 commit comments

Comments
 (0)