fix Esc closing the editor instead of returning to Vim normal mode

panel.focusMode.exit is bound to Escape in the contributions layer, which
outranks the active preset. In Vim insert/visual mode that shadowed the
vim preset's `escape → vim.mode.normal` binding, so Esc closed the editor
instead of returning to normal mode.

Add an optional when-clause to a CommandContribution's defaultBinding
(plumbed through to KeymapService.registerCommandBinding, which already
accepts one) and guard focusMode.exit's escape with
`!vim.insert && !vim.visual` — symmetric with vim.yaml's vim.mode.normal.
Esc still exits focus / closes the editor in normal and non-Vim modes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 20:58:14 +02:00
co-authored by Claude Opus 4.8
parent f0fa602ff4
commit 635ae04dae
7 changed files with 87 additions and 1 deletions
+1 -1
View File
@@ -205,7 +205,7 @@ class ExtensionManager extends ChangeNotifier {
// until all callers migrate; the keymap layer is the
// canonical home for chord → command bindings (T-117).
keybindings.bind(Keybinding.parse(binding), cmd.command);
keymap.registerCommandBinding(binding, cmd.command);
keymap.registerCommandBinding(binding, cmd.command, when: cmd.bindingWhen);
}
case TrayItemContribution t:
tray.add(t);