WSL port 7/7: bind the quit chord that WSL actually sends
Stacked on #12. Found by pressing the key — which is exactly what checkpoint 5
said would be needed, because nothing automated can reach this.
What was wrong
Ctrl+Shift+Q did nothing on WSL.
Windows Terminal 1.24 is new enough to speak CSI-u and does not negotiate it
with nvim. So the chord arrives as the legacy 0x11 — plain <C-q> — and the
<C-S-q> mapping is never reached. The documented way out of the editor did not
exist on WSL, leaving :qa! — the one thing that whole section of the config
was written to stop being necessary.
Why no test caught it
suite_quit.shwritesESC[113;6ustraight onto the pty, so it passes on
a terminal where the chord could never arrive.demo.sh --checkcannot send CSI-u over--remote-sendat all (checkpoint 4).vim.g.termfeaturesisnileven in a real TUI on nvim 0.12, so there is no
runtime signal to detect CSI-u from Lua either.
This one genuinely required a human to press it.
The fix
Bind what actually arrives. This is not a second key to learn — you press
Ctrl+Shift+Q, exactly as documented, and <C-q> is what nvim is handed.
Insert only, and gated on WSL, because both halves cost something:
- normal mode keeps
Ctrl+Qas visual block — it is the only way to ask for
one, and drill's premise is that you are in insert anyway - in insert, vanilla
<C-q>is literal-insert, the twin of<C-v>. In a
Python scratchpad where<C-v>is already paste that is close to unreachable,
and a quit prompt defaulting to Cancel is the better use of the key. But it is
a real vim behaviour, so nowhere but WSL loses it.
Verification — both branches, forced each way
On WSL:
insert <C-q> : -> quit_drill (callback)
normal <C-q> : <C-V>
insert <C-S-q> : -> quit_drill (callback)
insert <C-v> : <C-R><C-O>+
Forced non-WSL — what a Mac sees:
insert <C-q> : UNMAPPED (vanilla literal-insert)
normal <C-q> : <C-V>
insert <C-S-q> : -> quit_drill
insert <C-v> : <C-R><C-O>+
Byte-for-byte the old behaviour off WSL.
Suite: 556/556, ALL SUITES PASSED. Every <C-q> case in the suite is
normal-mode (suite_options.sh asserts it maps to <C-V>; suite_comment.sh's
visual-block case is --start normal), so none of them touch the new binding.
The WSL probe is hoisted to one IS_WSL near the top, since the clipboard
fallback asks the same question.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WveBqAyhoM49p9gWfwBDBx
Summary by cubic
Make the quit chord work on WSL by binding what Windows Terminal actually sends. On WSL, insert- and terminal‑mode <C-q> opens the quit prompt; normal‑mode <C-q> stays visual block. Off WSL, behavior is unchanged.
-
Bug Fixes
- WSL: map insert- and terminal‑mode
<C-q>to the quit prompt because Windows Terminal 1.24 doesn’t negotiate CSI‑u withnvimand sends 0x11; lets you quit from inside the REPL while keeping normal‑mode<C-q>for visual block. - Docs: clarify the
IS_WSLgate (env, not protocol), the normal‑mode gap on non‑CSI‑u terminals, terminal‑mode quit, the insert‑mode literal‑insert trade‑off, and retract the earlier--remote-sendcollapse claim.
- WSL: map insert- and terminal‑mode
-
Refactors
- Hoisted a single
IS_WSLprobe and applied the fallback in insert and terminal modes. - Tests: add
suite_options.shchecks to ensure the<C-q>fallback binds only on WSL (i/t) and does not leak to Linux CI. - Comments: note
readlinebinds^Qto quoted‑insert; the fallback trades it for quit, with^Vstill providing quoted‑insert.
- Hoisted a single
Summary by CodeRabbit
- New Features
- Added WSL support for terminals that send
Ctrl+Shift+QasCtrl+Q. - In insert and terminal modes, the shortcut now opens the quit prompt; normal-mode
Ctrl+Qretains visual-block selection. - Terminals supporting CSI-u continue to use the dedicated
Ctrl+Shift+Qbehavior.
- Added WSL support for terminals that send
- Documentation
- Clarified terminal compatibility, WSL-specific key behavior, quit instructions, and automated testing limitations.
Greptile Summary
The PR makes the documented quit chord work when Windows Terminal sends its legacy <C-q> encoding under WSL.
- Adds a WSL-gated
<C-q>fallback in insert and terminal modes while preserving normal-mode visual block. - Documents the CSI-u limitation and intentional keybinding trade-offs.
- Adds platform-sensitive assertions that the fallback is present only on WSL.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains; the current WSL-gated mapping includes both insert and terminal modes, so the previously reported missing REPL fallback is fixed.
Important Files Changed
| Filename | Overview |
|---|---|
| nvimrc.lua | Adds the missing terminal-mode fallback alongside insert mode, fully addressing the previous review thread while preserving normal-mode <C-q>. |
| tests/suite_options.sh | Verifies that callback mappings exist in insert and terminal modes exactly when the shared WSL detection is true. |
| KEYS.md | Documents the non-CSI-u normal-mode limitation and the WSL-specific fallback behavior. |
| docs/wsl.md | Explains the terminal encoding behavior, affected modes, and deliberate loss of literal insert on WSL. |
| TODO.md | Updates checkpoint evidence and records the manually verified WSL key-encoding behavior. |
Reviews (25): Last reviewed commit: "Test the WSL quit fallback, and stop cal..." | Re-trigger Greptile