diff --git a/components/terminal/autocomplete/terminalAutocompleteKeyEvent.ts b/components/terminal/autocomplete/terminalAutocompleteKeyEvent.ts index 396a17004..538961d00 100644 --- a/components/terminal/autocomplete/terminalAutocompleteKeyEvent.ts +++ b/components/terminal/autocomplete/terminalAutocompleteKeyEvent.ts @@ -36,8 +36,9 @@ export function autocompleteEscMetaFollowUpSequence(e: { metaKey: boolean; shiftKey: boolean; }): string | null { - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return null; - if (e.key === ".") return "\x1b."; + if (e.altKey || e.ctrlKey || e.metaKey) return null; + // `_` is Shift+Minus on a standard keyboard; Shift+. is `>` and must not yank. + if (e.key === "." && !e.shiftKey) return "\x1b."; if (e.key === "_") return "\x1b_"; return null; } diff --git a/components/terminal/terminalAutocompleteKeyEvent.test.ts b/components/terminal/terminalAutocompleteKeyEvent.test.ts index b4e82bc18..55bc4c9bb 100644 --- a/components/terminal/terminalAutocompleteKeyEvent.test.ts +++ b/components/terminal/terminalAutocompleteKeyEvent.test.ts @@ -234,6 +234,22 @@ test("Esc+. after dismissing the popup sends ESC+. to the shell", () => { assert.deepEqual(writes, ["\x1b."]); }); +test("Esc then Shift+. does not yank (Shift+. is >)", () => { + const { context, writes } = createContext(); + handleTerminalAutocompleteKeyEvent(keyEvent("Escape"), context); + context.stateRef.current = { + ...context.stateRef.current, + popupVisible: false, + suggestions: [], + }; + + const greaterThan = shiftKeyEvent(">"); + const result = handleTerminalAutocompleteKeyEvent(greaterThan, context); + + assert.equal(result, true); + assert.deepEqual(writes, []); +}); + test("Esc+_ after dismissing the popup sends ESC+_ to the shell", () => { const { context, writes } = createContext(); handleTerminalAutocompleteKeyEvent(keyEvent("Escape"), context); @@ -243,7 +259,7 @@ test("Esc+_ after dismissing the popup sends ESC+_ to the shell", () => { suggestions: [], }; - const underscore = keyEvent("_"); + const underscore = shiftKeyEvent("_"); const result = handleTerminalAutocompleteKeyEvent(underscore, context); assert.equal(result, false);