fix(coding-agent): preserve copy-prompt retry collision
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user