fix: suppress input text for kitty release events

Release events now produce empty input to prevent character duplication
when reportEventTypes flag is enabled. key.eventType is still passed
through so handlers can detect release events.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-27 15:35:07 +08:00
parent facfc3f53e
commit 978a29145b
3 changed files with 10 additions and 3 deletions
@@ -99,6 +99,11 @@ const KittyInput = defineComponent({
return;
}
if (props.test === "releaseEmpty" && input === "" && key.eventType === "release") {
exit();
return;
}
if (props.test === "queryResponse") {
throw new Error("Query response should not reach handler");
}
@@ -66,8 +66,8 @@ it("useInput - handle kitty protocol repeat event", async () => {
expect(ps.output).toContain("exited");
});
it("useInput - handle kitty protocol release event", async () => {
const ps = term("use-input-kitty", ["release"]);
it("useInput - release event produces empty input", async () => {
const ps = term("use-input-kitty", ["releaseEmpty"]);
ps.write(kittyKey(97, 1, 3));
await ps.waitForExit();
expect(ps.output).toContain("exited");
+3 -1
View File
@@ -70,7 +70,9 @@ export function useInput(
let input: string;
if (keypress.isKittyProtocol) {
if (keypress.isPrintable) {
if (keypress.eventType === "release") {
input = "";
} else if (keypress.isPrintable) {
input = keypress.text ?? keypress.name;
} else if (keypress.ctrl && keypress.name.length === 1) {
input = keypress.name;