test(tui): isolate Windows Terminal backspace env coverage (#3220)
This commit is contained in:
@@ -18,6 +18,19 @@ function withEnv(name: string, value: string | undefined, fn: () => void): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withEnvVars(vars: Record<string, string | undefined>, fn: () => void): void {
|
||||||
|
const entries = Object.entries(vars);
|
||||||
|
const run = (index: number): void => {
|
||||||
|
if (index >= entries.length) {
|
||||||
|
fn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [name, value] = entries[index]!;
|
||||||
|
withEnv(name, value, () => run(index + 1));
|
||||||
|
};
|
||||||
|
run(0);
|
||||||
|
}
|
||||||
|
|
||||||
describe("matchesKey", () => {
|
describe("matchesKey", () => {
|
||||||
describe("Kitty protocol with alternate keys (non-Latin layouts)", () => {
|
describe("Kitty protocol with alternate keys (non-Latin layouts)", () => {
|
||||||
// Kitty protocol flag 4 (Report alternate keys) sends:
|
// Kitty protocol flag 4 (Report alternate keys) sends:
|
||||||
@@ -351,14 +364,40 @@ describe("matchesKey", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should treat raw 0x08 as ctrl+backspace in Windows Terminal", () => {
|
it("should treat raw 0x08 as ctrl+backspace in local Windows Terminal", () => {
|
||||||
setKittyProtocolActive(false);
|
setKittyProtocolActive(false);
|
||||||
withEnv("WT_SESSION", "test-session", () => {
|
withEnvVars(
|
||||||
assert.strictEqual(matchesKey("\x08", "ctrl+backspace"), true);
|
{
|
||||||
assert.strictEqual(matchesKey("\x08", "backspace"), false);
|
WT_SESSION: "test-session",
|
||||||
assert.strictEqual(parseKey("\x08"), "ctrl+backspace");
|
SSH_CONNECTION: undefined,
|
||||||
assert.strictEqual(matchesKey("\x08", "ctrl+h"), true);
|
SSH_CLIENT: undefined,
|
||||||
});
|
SSH_TTY: undefined,
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
assert.strictEqual(matchesKey("\x08", "ctrl+backspace"), true);
|
||||||
|
assert.strictEqual(matchesKey("\x08", "backspace"), false);
|
||||||
|
assert.strictEqual(parseKey("\x08"), "ctrl+backspace");
|
||||||
|
assert.strictEqual(matchesKey("\x08", "ctrl+h"), true);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should treat raw 0x08 as plain backspace in Windows Terminal over SSH", () => {
|
||||||
|
setKittyProtocolActive(false);
|
||||||
|
withEnvVars(
|
||||||
|
{
|
||||||
|
WT_SESSION: "test-session",
|
||||||
|
SSH_CONNECTION: "1 2 3 4",
|
||||||
|
SSH_CLIENT: "1 2 3",
|
||||||
|
SSH_TTY: "/dev/pts/1",
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
assert.strictEqual(matchesKey("\x08", "ctrl+backspace"), false);
|
||||||
|
assert.strictEqual(matchesKey("\x08", "backspace"), true);
|
||||||
|
assert.strictEqual(parseKey("\x08"), "backspace");
|
||||||
|
assert.strictEqual(matchesKey("\x08", "ctrl+h"), true);
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should parse legacy alt-prefixed sequences when kitty inactive", () => {
|
it("should parse legacy alt-prefixed sequences when kitty inactive", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user