fix(tui): complete super key helper support closes #2979
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
import assert from "node:assert";
|
||||
import { describe, it } from "node:test";
|
||||
import { decodeKittyPrintable, matchesKey, parseKey, setKittyProtocolActive } from "../src/keys.js";
|
||||
import { decodeKittyPrintable, Key, matchesKey, parseKey, setKittyProtocolActive } from "../src/keys.js";
|
||||
|
||||
function withEnv(name: string, value: string | undefined, fn: () => void): void {
|
||||
const previous = process.env[name];
|
||||
@@ -66,6 +66,21 @@ describe("matchesKey", () => {
|
||||
setKittyProtocolActive(false);
|
||||
});
|
||||
|
||||
it("should match super-modified Kitty bindings, including combined modifiers", () => {
|
||||
setKittyProtocolActive(true);
|
||||
assert.strictEqual(matchesKey("\x1b[107;9u", "super+k"), true);
|
||||
assert.strictEqual(matchesKey("\x1b[13;9u", "super+enter"), true);
|
||||
assert.strictEqual(matchesKey("\x1b[107;13u", Key.ctrlSuper("k")), true);
|
||||
assert.strictEqual(matchesKey("\x1b[107;13u", "ctrl+super+k"), true);
|
||||
assert.strictEqual(matchesKey("\x1b[107;14u", "ctrl+shift+super+k"), true);
|
||||
assert.strictEqual(matchesKey("\x1b[107;13u", "super+k"), false);
|
||||
assert.strictEqual(parseKey("\x1b[107;9u"), "super+k");
|
||||
assert.strictEqual(parseKey("\x1b[13;9u"), "super+enter");
|
||||
assert.strictEqual(parseKey("\x1b[107;13u"), "ctrl+super+k");
|
||||
assert.strictEqual(parseKey("\x1b[107;14u"), "shift+ctrl+super+k");
|
||||
setKittyProtocolActive(false);
|
||||
});
|
||||
|
||||
it("should match digit bindings via Kitty CSI-u", () => {
|
||||
setKittyProtocolActive(true);
|
||||
assert.strictEqual(matchesKey("\x1b[49u", "1"), true);
|
||||
@@ -474,7 +489,7 @@ describe("parseKey", () => {
|
||||
|
||||
it("should ignore Kitty CSI-u with unsupported modifiers", () => {
|
||||
setKittyProtocolActive(true);
|
||||
assert.strictEqual(parseKey("\x1b[99;9u"), undefined);
|
||||
assert.strictEqual(parseKey("\x1b[99;17u"), undefined);
|
||||
setKittyProtocolActive(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user