From 15b36cbee102c5638b6b2e7d18b9c352c2e59e8c Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 6 Mar 2026 16:41:00 +0100 Subject: [PATCH] feat(coding-agent): preserve custom editor onEscape/onCtrlD handlers Only set app-level handlers on custom editors if they haven't defined their own. This allows custom editors (e.g. vim mode) to implement custom escape handling instead of being overwritten. Closes #1838 --- .../src/modes/interactive/interactive-mode.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts index fa2e8064..bc1955d4 100644 --- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts +++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts @@ -1634,10 +1634,18 @@ export class InteractiveMode { // Use duck typing since instanceof fails across jiti module boundaries const customEditor = newEditor as unknown as Record; if ("actionHandlers" in customEditor && customEditor.actionHandlers instanceof Map) { - customEditor.onEscape = () => this.defaultEditor.onEscape?.(); - customEditor.onCtrlD = () => this.defaultEditor.onCtrlD?.(); - customEditor.onPasteImage = () => this.defaultEditor.onPasteImage?.(); - customEditor.onExtensionShortcut = (data: string) => this.defaultEditor.onExtensionShortcut?.(data); + if (!customEditor.onEscape) { + customEditor.onEscape = () => this.defaultEditor.onEscape?.(); + } + if (!customEditor.onCtrlD) { + customEditor.onCtrlD = () => this.defaultEditor.onCtrlD?.(); + } + if (!customEditor.onPasteImage) { + customEditor.onPasteImage = () => this.defaultEditor.onPasteImage?.(); + } + if (!customEditor.onExtensionShortcut) { + customEditor.onExtensionShortcut = (data: string) => this.defaultEditor.onExtensionShortcut?.(data); + } // Copy action handlers (clear, suspend, model switching, etc.) for (const [action, handler] of this.defaultEditor.actionHandlers) { (customEditor.actionHandlers as Map void>).set(action, handler);