Let Ctrl+V reach the agent on macOS, and leave Cmd+V to the webview's own paste

AI Assisted
This commit is contained in:
Seth committed 2026-12-05 00:10:45 -08:00
1 parent b629f5ef04
commit 91479b21a1
3 files changed
+36 -3

No files matched your search

+5 -2
View File
@@ -774,7 +774,10 @@ export function shortcutFromMessage(data) {
* What a key press does in the terminal's clipboard handling: "copy" (Ctrl+Shift+C, Cmd+C, and
* Ctrl+C while text is selected, the Windows Terminal rule: with nothing selected Ctrl+C is the
* interrupt and returns null), "paste" (Ctrl+V, Ctrl+Shift+V, Cmd+V), or null. With `mac`, a plain
* Ctrl+C is always the interrupt, as in every macOS terminal: copy there is Cmd+C.
* Ctrl+C is always the interrupt, as in every macOS terminal: copy there is Cmd+C. Ctrl+V belongs to
* the agent there too (Claude Code pastes an image with it), and Cmd+V returns null as well: it is
* left to the webview's own paste event, which xterm takes as one paste, because reading the
* clipboard from script makes WebKit ask with a Paste menu before the text arrives.
*/
export function clipboardAction(event, hasSelection, { mac = false } = {}) {
if (!event || event.altKey) return null;
@@ -784,7 +787,7 @@ export function clipboardAction(event, hasSelection, { mac = false } = {}) {
if (event.ctrlKey && !event.metaKey) return event.shiftKey || (hasSelection && !mac) ? 'copy' : null;
return null;
}
if (key === 'v' && (event.ctrlKey || event.metaKey)) return 'paste';
if (key === 'v' && !mac && (event.ctrlKey || event.metaKey)) return 'paste';
return null;
}
+1 -1
View File
@@ -139,7 +139,7 @@ export async function mountTerminal(container, { onInput, onResize, onFontSize,
// Ctrl+C copies while text is selected and is the interrupt otherwise (the Windows Terminal
// rule; on a Mac it is always the interrupt); Ctrl+Shift+C and Cmd+C always copy.
// preventDefault on the paste keys: the browser's own paste event would otherwise reach the
// terminal a second time.
// terminal a second time. On a Mac no key is a paste key here: Cmd+V is that own paste event.
const action = clipboardAction(event, term.hasSelection(), { mac: IS_MAC });
if (action === 'copy') {
copySelection();