mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 03:50:52 +00:00
fix(terminal): keep Esc+_ armed across the Shift keydown
Typing underscore emits Shift before Minus. Clearing the Meta prefix on that modifier event dropped M-_ after autocomplete dismiss. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f960f4c78e
commit
b0839dbaad
2 files changed
+21
-1
No files matched your search
@@ -88,7 +88,7 @@ export function handleTerminalAutocompleteKeyEvent(
|
||||
writeToTerminal(metaFollowUp);
|
||||
return false;
|
||||
}
|
||||
if (e.key !== "Escape") {
|
||||
if (e.key !== "Escape" && e.key !== "Shift" && e.key !== "Control" && e.key !== "Alt" && e.key !== "Meta") {
|
||||
escMetaPrefixUntilRef.current = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,26 @@ test("Esc+_ after dismissing the popup sends ESC+_ to the shell", () => {
|
||||
assert.deepEqual(writes, ["\x1b_"]);
|
||||
});
|
||||
|
||||
test("Esc then Shift keydown then _ still yanks (Shift is a separate event)", () => {
|
||||
const { context, writes } = createContext();
|
||||
handleTerminalAutocompleteKeyEvent(keyEvent("Escape"), context);
|
||||
context.stateRef.current = {
|
||||
...context.stateRef.current,
|
||||
popupVisible: false,
|
||||
suggestions: [],
|
||||
};
|
||||
|
||||
const shiftDown = shiftKeyEvent("Shift");
|
||||
assert.equal(handleTerminalAutocompleteKeyEvent(shiftDown, context), true);
|
||||
assert.ok(context.escMetaPrefixUntilRef.current > 1_000);
|
||||
|
||||
const underscore = shiftKeyEvent("_");
|
||||
const result = handleTerminalAutocompleteKeyEvent(underscore, context);
|
||||
|
||||
assert.equal(result, false);
|
||||
assert.deepEqual(writes, ["\x1b_"]);
|
||||
});
|
||||
|
||||
test("Esc then a non-Meta follow-up does not inject ESC and lets the key through", () => {
|
||||
const { context, writes } = createContext();
|
||||
handleTerminalAutocompleteKeyEvent(keyEvent("Escape"), context);
|
||||
|
||||
Reference in new issue
Block a user