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:
@@ -79,6 +79,10 @@ class DefaultLayoutExtension extends ClideExtension {
|
||||
command: 'panel.focusMode.exit',
|
||||
title: 'Exit Focus Mode',
|
||||
defaultBinding: 'escape',
|
||||
// Stand down in Vim insert/visual mode so Esc returns to normal
|
||||
// mode instead of closing the editor (T-257). Symmetric with
|
||||
// vim.yaml's `vim.mode.normal` (escape when vim.insert||vim.visual).
|
||||
bindingWhen: '!vim.insert && !vim.visual',
|
||||
run: _exitFocusMode,
|
||||
),
|
||||
// Editor split (D-049, D-054)
|
||||
|
||||
@@ -107,11 +107,18 @@ class CommandContribution extends ContributionPoint {
|
||||
required this.run,
|
||||
this.title,
|
||||
this.defaultBinding,
|
||||
this.bindingWhen,
|
||||
});
|
||||
|
||||
final String command; // e.g. "git.commit"
|
||||
final String? title; // "Git: Commit staged"
|
||||
final String? defaultBinding; // e.g. "ctrl+shift+g"
|
||||
|
||||
/// Optional when-clause guarding [defaultBinding] (same grammar as keymap
|
||||
/// YAML `when:`). Lets a global binding yield to a higher-context one — e.g.
|
||||
/// `panel.focusMode.exit`'s `escape` stands down in Vim insert/visual mode so
|
||||
/// the preset's `vim.mode.normal` wins (T-257). Null → binding always active.
|
||||
final String? bindingWhen;
|
||||
final Future<IpcResponse> Function(List<String> args) run;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user