Ctrl+H (delete previous character) is misinterpreted as Ctrl+Backspace (delete word) under WSL2 due to WT_SESSION leaking from Windows Terminal
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, linux, node.js
- 领域
- cli, operating-systems
调研方向
从打包后的 app.js 中的 fSt() 及其 reader 初始化开始,然后在检查 ZDe() 之前,验证 WT_SESSION 和 process.platform 如何影响 ctrlHIsCtrlBackspace。在设置和未设置 WT_SESSION 的情况下于 WSL2 中复现;当 Ctrl+H 删除一个字符且原生 Windows 行为保持不变时即完成。
由索引模型根据 Issue 内容生成。
描述
Description
/help documents ctrl+h as "delete previous character", but under WSL2 it instead deletes the whole previous word (i.e. behaves like ctrl+w/Ctrl+Backspace).
Environment
- Copilot CLI version: 1.0.78-2
- Platform: WSL2 (
Linux ... 6.18.33.2-microsoft-standard-WSL2), Windows Terminal as host, plainxterm-256colorinside (issue reproduces both inside and outside tmux) WSLENV=WT_SESSION:WT_PROFILE_ID:(default WSL/Windows Terminal integration), soWT_SESSIONis present in the WSL shell environment even though the CLI is not running as a native Windows process
Root cause
In the bundled app.js, the raw-byte key decoder special-cases byte 0x08 (\b) — which is exactly what Ctrl+H sends — as Ctrl+Backspace when a ctrlHIsCtrlBackspace flag is set:
function ZDe(t, e=!1) {
return t.length!==1 ? null
: t==="\r" ? {code:"return"}
: ...
: t==="\b" && e ? {code:"backspace", ctrl:!0} // <-- Ctrl+H reinterpreted as Ctrl+Backspace
: t==="\b" || t==="\x7F" ? {code:"backspace"}
: ...
}
The flag is computed once at startup:
reader = new ope({ ctrlHIsCtrlBackspace: fSt() })
function Nk() { return !RA() && !process.env.TMUX && !process.env.STY }
function fSt() { return process.platform==="win32" && Nk() || !!process.env.WT_SESSION }
The intent is reasonable on native Windows (Windows Console/Windows Terminal apps can't distinguish a literal Ctrl+H keypress from Ctrl+Backspace, since both produce byte 0x08), so trading away the Ctrl+H binding there makes sense. However, the || !!process.env.WT_SESSION clause has no accompanying process.platform==="win32" check, so it also fires under WSL2, where WT_SESSION is forwarded into the Linux environment by WSLENV for terminal-integration purposes, but the CLI is actually running in a normal Linux pty where Ctrl+H and Ctrl+Backspace are distinguishable. This causes a false positive: the workaround for a Windows-only ambiguity ends up breaking a real, distinguishable keybinding on WSL.
This also affects users in the reverse scenario, if WT_SESSION is otherwise present in the environment (e.g. propagated through SSH or subshells) on non-Windows platforms.
Steps to reproduce
- Launch Copilot CLI inside WSL2 under Windows Terminal (default
WSLENVintegration). - Type some text, then press Ctrl+H.
- Expected: deletes one character before the cursor (per
/help). - Actual: deletes the entire previous word.
Suggested fix
Gate the WT_SESSION check on process.platform === "win32" as well, e.g.:
function fSt() {
return process.platform === "win32" && (Nk() || !!process.env.WT_SESSION);
}
or otherwise detect WSL (e.g. via /proc/version containing "microsoft" or process.platform !== "win32") and skip the ctrlHIsCtrlBackspace heuristic in that case.
Workaround
unset WT_SESSION before launching copilot restores the documented Ctrl+H behavior.
- 主要语言
- Shell
- 星标
- 11.2k
- 派生
- 1.9k
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 6
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/copilot-cli 的其他 Issue
-
triage
难度 2/5 1-3 小时 新手友好度 72/100
github/copilot-cli#4848 ·
-
area:agents area:mcp
难度 2/5 1-3 小时 新手友好度 72/100
github/copilot-cli#4729 ·
-
area:sessions
难度 2/5 1-3 小时 新手友好度 72/100
github/copilot-cli#4712 ·
-
triage
难度 2/5 1-3 小时 新手友好度 75/100
github/copilot-cli#4638 ·
-
Expose large_output_file_path on TaskShellProgress so clients can read complete shell-task output 未关闭area:tools
难度 2/5 1-3 小时 新手友好度 78/100
github/copilot-cli#4630 · 1 条评论 ·
查看 github/copilot-cli 的全部 Issue
相似的 Issue
-
out-of-date
难度 1/5 1 小时以内 新手友好度 82/100
CachyOS/CachyOS-PKGBUILDS#1894 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
community-scripts/ProxmoxVE#17396 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
mattpocock/skills#1099 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 75/100