Is there a way to modify the shortcuts so pressing escape
in the find widget (the red dot) gives the editor (the green dot) focus without closing the find widget?
I've done a little research on my own, and I think I'll have to make two changes for this:
- I will have to add
escape
to a shortcut that gives the editor focus. I've found one that does this, namedView: Focus Active Editor Group
. There is probably a better fitting shortcut I could be using instead, and I'd like to know what it is. - I will have to remove the shortcut that closes the search widget when it has focus and you press the
escape
key.
I'm completely lost on that second point. There's a shortcut called Search: Cancel Search
which seems like the obvious choice, but it's "when" column suggests otherwise: listFocus && searchViewletVisible && !inputFocus && searchState != '0'
First of all, I don't know what listFocus
means, and the official documentation doesn't explain. Second, !inputFocus
does not seem like the scenario I'm trying to change.
Third, it's nontrivial to search for the escape
key shortcuts, since it closes the search dialog. Fortunately, I figured out that this can be done by typing "escape"
into the keyboard shortcut search. I'm providing this information to others because they may need to know this to help me.
If I press escape in the search widget, the keyboard debugging says:
[2022-05-06 04:03:00.883] [renderer1] [info] [KeybindingService]: / Received keydown event - modifiers: [], code: Escape, keyCode: 27, key: Escape
[2022-05-06 04:03:00.883] [renderer1] [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: Escape, keyCode: 9 ('Escape')
[2022-05-06 04:03:00.883] [renderer1] [info] [KeybindingService]: | Resolving Escape
[2022-05-06 04:03:00.883] [renderer1] [info] [KeybindingService]: \ From 52 keybinding entries, matched closeFindWidget, when: editorFocus && findWidgetVisible && !isComposing, source: built-in.
CodePudding user response:
Define this in your keybindings,json
The last key binding that matches the key and when
is used (search is done from the bottom)
{ "key": "escape",
"command": "workbench.action.focusActiveEditorGroup",
"when": "findInputFocussed && findWidgetVisible || replaceInputFocussed && findWidgetVisible"
}
The when
clause looks weird but that is because you cant use ()
.