diff --git a/packages/coding-agent/src/modes/components/custom-editor.ts b/packages/coding-agent/src/modes/components/custom-editor.ts index 9e27cbb4b..195a16f13 100644 --- a/packages/coding-agent/src/modes/components/custom-editor.ts +++ b/packages/coding-agent/src/modes/components/custom-editor.ts @@ -586,9 +586,16 @@ export class CustomEditor extends Editor { return; } + // Intercept configured copy-prompt shortcut + if (this.#matchesAction(canonical, "app.clipboard.copyPrompt") && this.onCopyPrompt) { + this.onCopyPrompt(); + return; + } + // Intercept configured retry shortcut. Later user/custom handlers keep // precedence so adding the default Alt+R binding does not steal existing - // shortcuts such as app.plan.toggle or extension commands. + // shortcuts such as app.plan.toggle or extension commands; copy-prompt is + // checked above for the same reason. if (this.#matchesAction(canonical, "app.retry") && this.onRetry) { const customHandler = this.#customMatchKeys.get(canonical); if (customHandler) { @@ -599,12 +606,6 @@ export class CustomEditor extends Editor { return; } - // Intercept configured copy-prompt shortcut - if (this.#matchesAction(canonical, "app.clipboard.copyPrompt") && this.onCopyPrompt) { - this.onCopyPrompt(); - return; - } - // Check custom key handlers (extensions) const handler = this.#customMatchKeys.get(canonical); if (handler) { diff --git a/packages/coding-agent/test/custom-editor-keybindings.test.ts b/packages/coding-agent/test/custom-editor-keybindings.test.ts index e0f3a71fa..dc0a63e37 100644 --- a/packages/coding-agent/test/custom-editor-keybindings.test.ts +++ b/packages/coding-agent/test/custom-editor-keybindings.test.ts @@ -30,4 +30,18 @@ describe("CustomEditor keybindings", () => { expect(customHandler).toHaveBeenCalledTimes(1); expect(onRetry).not.toHaveBeenCalled(); }); + + it("lets copy-prompt remaps keep precedence over the default retry chord", () => { + const editor = new CustomEditor(getEditorTheme()); + const onRetry = vi.fn(); + const onCopyPrompt = vi.fn(); + + editor.onRetry = onRetry; + editor.onCopyPrompt = onCopyPrompt; + editor.setActionKeys("app.clipboard.copyPrompt", ["alt+r"]); + editor.handleInput("\x1br"); + + expect(onCopyPrompt).toHaveBeenCalledTimes(1); + expect(onRetry).not.toHaveBeenCalled(); + }); });