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
This commit is contained in:
Mario Zechner
2026-03-06 16:41:00 +01:00
parent b8910f13ad
commit 15b36cbee1

View File

@@ -1634,10 +1634,18 @@ export class InteractiveMode {
// Use duck typing since instanceof fails across jiti module boundaries
const customEditor = newEditor as unknown as Record<string, unknown>;
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<string, () => void>).set(action, handler);