Ctrl+Shift+C (and Ctrl+C with a selection) send ^C instead of copying on Linux/Windows
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
按键处理逻辑位于 lib/input-handler.ts 中的 handleKeyDown,目前它只对 metaKey 加 KeyC 做了特殊处理,并调用已有的 onCopyCallback。运行 issue 中的复现片段,确认带有 ctrlKey 和 shiftKey 的 keydown 仍会以 "\u0003" 的形式传给 onData。完成标准是:Ctrl+Shift+C 调用复制回调,且不向 PTY 发送任何内容;Ctrl+C 只在存在选区时复制,否则仍发送 ^C。另外检查 Cmd+C 路径的行为保持不变。
由索引模型根据 Issue 内容生成。
描述
Summary
On Linux and Windows there is no keyboard way to copy the terminal selection: Ctrl+Shift+C (the terminal copy chord everywhere on those platforms) is passed to the key encoder and sent to the PTY as ^C (0x03), and plain Ctrl+C with text selected also sends ^C. Only Cmd+C (macOS, event.metaKey && event.code === 'KeyC') triggers the copy path. In a shell this means the user selects text, presses the copy shortcut, and interrupts their running program.
Seen on [email protected]; main (lib/input-handler.ts) still only special-cases metaKey + KeyC.
Minimal reproduction
<div id="t"></div>
<script type="module">
import { init, Terminal } from 'ghostty-web';
await init();
const term = new Terminal();
term.open(document.getElementById('t'));
term.onData((d) => console.log(JSON.stringify(d)));
term.write('hello world');
term.select(0, 0, 5); // "hello"
console.log(term.getSelection()); // "hello"
term.focus();
term.element.dispatchEvent(new KeyboardEvent('keydown', { key: 'C', code: 'KeyC', ctrlKey: true, shiftKey: true, bubbles: true, cancelable: true }));
</script>
Actual: onData receives "\u0003"; the clipboard is untouched. Expected: the selection is copied and nothing is sent to the PTY (Ctrl+Shift+C), and ideally Ctrl+C copies instead of interrupting when a selection exists (xterm.js users get this from attachCustomKeyEventHandler; Windows Terminal and GNOME Terminal behave this way).
Suggested fix
In handleKeyDown, treat (ctrlKey && shiftKey && code === 'KeyC') as copy using the existing onCopyCallback (always swallow it, never forward ^C), and ctrlKey && !shiftKey && code === 'KeyC' as copy when onCopyCallback() reports a selection.
Found while evaluating ghostty-web as a PTY renderer for https://github.com/erisera-code/clawser; the host currently works around it with attachCustomKeyEventHandler.
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 182
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/ghostty-web 的其他 Issue
-
buffer translateToString()/getChars() return '' for empty cells, collapsing cursor-positioned text未关闭
难度 2/5 1-3 小时 新手友好度 75/100
coder/ghostty-web#205 ·
-
Alt+<printable key> sends the bare key with no ESC prefix (readline/emacs/tmux meta bindings lost)未关闭
难度 2/5 1-3 小时 新手友好度 72/100
coder/ghostty-web#203 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
coder/ghostty-web#199 ·
-
Public buffer getChars and translateToString truncate multi-codepoint graphemes可能已有人在做 @schickling-assistant 于 11 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 76/100
coder/ghostty-web#200 ·
-
难度 3/5 1-2 天 新手友好度 72/100
coder/ghostty-web#198 ·
查看 coder/ghostty-web 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
better-auth/better-auth#11723 · 1 个 reaction ·
维护者通常 1 天内回复
-
area: docs difficulty: easy documentation good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Worker-Erstellung bricht langsame Git-Worktree-Checkouts nach 20 Sekunden ab可能已有人在做 @KajoVanBuyten 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 69/100
AgentSystemLabs/agent-office#367 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
pierrecomputer/pierre#1187 ·
维护者通常 1 天内回复
-
area: frontend bug
难度 1/5 1-3 小时 新手友好度 85/100
snapotter-hq/SnapOtter#2425 ·
维护者通常 1 天内回复