From 55acb8a53965bd11d1b49769e2fda44b3a724b56 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 2 Apr 2026 14:09:52 +0700 Subject: [PATCH] fix(terminal): handle Ctrl+C/V for copy & paste on Windows/Linux On non-Mac platforms, let xterm.js ClipboardAddon handle Ctrl+C (copy when text is selected) and Ctrl+V (paste) instead of sending control codes to the PTY. Closes #175 --- .../src/terminal/runtime/terminal-emulator-runtime.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/app/src/terminal/runtime/terminal-emulator-runtime.ts b/packages/app/src/terminal/runtime/terminal-emulator-runtime.ts index e2a4b06f0..8dae88359 100644 --- a/packages/app/src/terminal/runtime/terminal-emulator-runtime.ts +++ b/packages/app/src/terminal/runtime/terminal-emulator-runtime.ts @@ -72,6 +72,11 @@ declare global { } } +const isMac = + typeof navigator !== "undefined" && + (/Macintosh|Mac OS/i.test(navigator.userAgent ?? "") || + /Mac/i.test((navigator as any).platform ?? "")); + const DEFAULT_TOUCH_SCROLL_LINE_HEIGHT_PX = 18; const FIT_TIMEOUT_DELAYS_MS = [0, 16, 48, 120, 250, 500, 1_000, 2_000]; const OUTPUT_OPERATION_TIMEOUT_MS = 5_000; @@ -280,6 +285,10 @@ export class TerminalEmulatorRuntime { return true; } + if (!isMac && event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) { + return true; + } + const normalizedKey = normalizeDomTerminalKey(event.key); if (!normalizedKey || isTerminalModifierDomKey(event.key)) { return true;