mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 16:42:19 +00:00
* feat(terminal): pass Esc+. through for readline yank-last-arg Autocomplete was swallowing Escape, and macOS Option+. typed ≥ instead of Meta-., so the standard shell shortcut never reached bash/zsh. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(terminal): allow Shift when Esc+_ yanks the last argument Underscore is Shift+Minus, so rejecting all shiftKey follow-ups dropped M-_ after autocomplete dismissed. Co-authored-by: Cursor <cursoragent@cursor.com> * 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> * fix(terminal): do not treat Esc+. as typed input Yank-last-arg rewrites the shell line. Walking the ESC+. bytes appended a literal period to the command buffer and left autocomplete's typed buffer marked reliable. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
export interface OptionYankLastArgKeyEvent {
|
|
key: string;
|
|
code?: string;
|
|
altKey: boolean;
|
|
ctrlKey: boolean;
|
|
metaKey: boolean;
|
|
shiftKey: boolean;
|
|
}
|
|
|
|
const isPeriodKey = (e: OptionYankLastArgKeyEvent): boolean => (
|
|
e.code === "Period" || e.key === "." || e.key === "≥"
|
|
);
|
|
|
|
const isUnderscoreKey = (e: OptionYankLastArgKeyEvent): boolean => (
|
|
e.key === "_" || (e.code === "Minus" && e.shiftKey)
|
|
);
|
|
|
|
/**
|
|
* macOS Option+. / Option+_ → readline yank-last-arg (issue #2364).
|
|
*
|
|
* Ghostty/iTerm2/kitty/VS Code do not implement this themselves — they pass
|
|
* Meta-. through to bash/zsh. On macOS, Option+. types "≥" unless Option is
|
|
* Meta, so map those two physical keys to ESC+. / ESC+_ without turning every
|
|
* Option chord into Meta (unlike `altAsMeta`).
|
|
*
|
|
* Gated to macOS: Linux/Windows Alt+. already sends the ESC prefix via xterm.
|
|
*/
|
|
export function optionYankLastArgSequence(
|
|
e: OptionYankLastArgKeyEvent,
|
|
isMac: boolean,
|
|
): string | null {
|
|
if (!isMac) return null;
|
|
if (!e.altKey || e.ctrlKey || e.metaKey) return null;
|
|
if (isPeriodKey(e) && !e.shiftKey) return "\x1b.";
|
|
if (isUnderscoreKey(e)) return "\x1b_";
|
|
return null;
|
|
}
|