From e90a6ee19f0ce802f8489f0ae6cc622394f7a94a Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 8 Jan 2024 07:30:49 -0600 Subject: [PATCH 1/2] input: never report associated text on key release Associated text should only be reported when it was generated from the key event. To my knowledge, there are no release events which produce text. This now matches kitty reporting for release events. --- src/input/KeyEncoder.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index 79c997144..6aa2e696f 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -186,7 +186,7 @@ fn kitty( } } - if (self.kitty_flags.report_associated) associated: { + if (self.kitty_flags.report_associated and seq.event != .release) associated: { if (comptime builtin.target.isDarwin()) { // macOS has special logic because alt+key can produce unicode // characters. If we are treating option as alt, then we do NOT From baf8e04287d22cf337c57cd5dba8af1b7b2e682d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 8 Jan 2024 08:12:54 -0800 Subject: [PATCH 2/2] input: add unit test for no associated text on release --- src/input/KeyEncoder.zig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index 6aa2e696f..c3f05d6d4 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -1364,6 +1364,29 @@ test "kitty: report associated" { try testing.expectEqualStrings("\x1b[106:74;2;74u", actual); } +test "kitty: report associated on release" { + var buf: [128]u8 = undefined; + var enc: KeyEncoder = .{ + .event = .{ + .action = .release, + .key = .j, + .mods = .{ .shift = true }, + .utf8 = "J", + .unshifted_codepoint = 106, + }, + .kitty_flags = .{ + .disambiguate = true, + .report_all = true, + .report_alternates = true, + .report_associated = true, + .report_events = true, + }, + }; + + const actual = try enc.kitty(&buf); + try testing.expectEqualStrings("[106:74;2:3u", actual[1..]); +} + test "kitty: alternates omit control characters" { var buf: [128]u8 = undefined; var enc: KeyEncoder = .{