fix(tui): distinguish ctrl+backspace from backspace on Windows Terminal

0x08 (BS) was treated as plain backspace alongside 0x7f (DEL). On
Windows Terminal, Backspace sends 0x7f and Ctrl+Backspace sends 0x08,
making ctrl+backspace bindings unreachable.

Now 0x08 matches ctrl+backspace (and ctrl+h, same byte) but not plain
backspace. 0x7f remains plain backspace.

fixes #2139
This commit is contained in:
Mario Zechner
2026-03-14 03:58:28 +01:00
parent 5c9ce47c53
commit 9c0ba357ad
3 changed files with 27 additions and 2 deletions

View File

@@ -252,6 +252,20 @@ describe("matchesKey", () => {
assert.strictEqual(parseKey("\x1b\x1f"), "ctrl+alt+-");
});
it("should distinguish backspace (0x7f) from ctrl+backspace (0x08)", () => {
setKittyProtocolActive(false);
// 0x7f is plain backspace
assert.strictEqual(matchesKey("\x7f", "backspace"), true);
assert.strictEqual(matchesKey("\x7f", "ctrl+backspace"), false);
assert.strictEqual(parseKey("\x7f"), "backspace");
// 0x08 is ctrl+backspace (Windows Terminal sends this for Ctrl+Backspace)
assert.strictEqual(matchesKey("\x08", "ctrl+backspace"), true);
assert.strictEqual(matchesKey("\x08", "backspace"), false);
assert.strictEqual(parseKey("\x08"), "ctrl+backspace");
// 0x08 also matches ctrl+h (same byte, ambiguous in legacy terminals)
assert.strictEqual(matchesKey("\x08", "ctrl+h"), true);
});
it("should parse legacy alt-prefixed sequences when kitty inactive", () => {
setKittyProtocolActive(false);
assert.strictEqual(matchesKey("\x1b ", "alt+space"), true);