From b2610b5fedc53bf009c0a33abc14645b3570f6ba Mon Sep 17 00:00:00 2001 From: Maximilian Wittmer Date: Mon, 2 Sep 2024 17:06:58 +0200 Subject: [PATCH] FindReplaceOverlay: add support from mnemonics from the Dialog In order to preserve the workflow of users who use the Mnemonics of the Find/Replace Dialog a lot, add support to these key combinations as well fixes #2080 --- .../findandreplace/overlay/FindReplaceOverlay.java | 14 +++++++++----- .../overlay/FindReplaceShortcutUtil.java | 2 +- 2 files changed, 10 insertions(+), 6 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 907a34d2a49..c3b29efc632 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 @@ -82,18 +82,22 @@ private final class KeyboardShortcuts { private static final List SEARCH_BACKWARD = List.of( // KeyStroke.getInstance(SWT.SHIFT, SWT.CR), KeyStroke.getInstance(SWT.SHIFT, SWT.KEYPAD_CR)); private static final List SEARCH_ALL = List.of( // + KeyStroke.getInstance(SWT.MOD1, SWT.CR), KeyStroke.getInstance(SWT.MOD1, SWT.KEYPAD_CR), + KeyStroke.getInstance(SWT.ALT, 's')); + private static final List REPLACE_ALL = List.of( // KeyStroke.getInstance(SWT.MOD1, SWT.CR), KeyStroke.getInstance(SWT.MOD1, SWT.KEYPAD_CR)); private static final List OPTION_CASE_SENSITIVE = List.of( // - KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'C'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'c')); + KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'C'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'c'), + KeyStroke.getInstance(SWT.ALT, 'c')); private static final List OPTION_WHOLE_WORD = List.of( // KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'D'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'd')); private static final List OPTION_REGEX = List.of( // KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'P'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'p')); private static final List OPTION_SEARCH_IN_SELECTION = List.of( // - KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'I'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'i')); + KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'I'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'i'), + KeyStroke.getInstance(SWT.ALT, 'l')); private static final List CLOSE = List.of( // - KeyStroke.getInstance(SWT.ESC), KeyStroke.getInstance(SWT.MOD1, 'F'), - KeyStroke.getInstance(SWT.MOD1, 'f')); + KeyStroke.getInstance(SWT.ESC), KeyStroke.getInstance(SWT.MOD1, 'F')); private static final List TOGGLE_REPLACE = List.of( // KeyStroke.getInstance(SWT.MOD1, 'R'), KeyStroke.getInstance(SWT.MOD1, 'r')); } @@ -527,7 +531,7 @@ private void createReplaceTools() { return; } performReplaceAll(); - }).withShortcuts(KeyboardShortcuts.SEARCH_ALL).build(); + }).withShortcuts(KeyboardShortcuts.REPLACE_ALL).build(); } private ContentAssistCommandAdapter createContentAssistField(HistoryTextWrapper control, boolean isFind) { diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceShortcutUtil.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceShortcutUtil.java index 0dd3a3a2810..c33b21a060a 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceShortcutUtil.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceShortcutUtil.java @@ -36,7 +36,7 @@ static private KeyStroke extractKeyStroke(KeyEvent e) { if (ctrlDown && e.character != e.keyCode && e.character < 0x20 && (e.keyCode & SWT.KEYCODE_BIT) == 0) { character += 0x40; } - KeyStroke actualStroke = KeyStroke.getInstance(e.stateMask & (SWT.MOD1 | SWT.SHIFT), + KeyStroke actualStroke = KeyStroke.getInstance(e.stateMask & (SWT.MOD1 | SWT.SHIFT | SWT.ALT), character == 0 ? e.keyCode : character); return actualStroke; }