From a67d90710c2db9d032502cd4688d55ca00697b60 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 24 Nov 2023 07:58:31 -0800 Subject: [PATCH] input: kitty encoding should ignore committed preedit state Fixes #952 --- src/input/KeyEncoder.zig | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index 31512086d..aa58f3953 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -87,6 +87,15 @@ fn kitty( return ""; } + // IME confirmation still sends an enter key so if we have enter + // and UTF8 text we just send it directly since we assume that is + // whats happening. + if (self.event.key == .enter and + self.event.utf8.len > 0) + { + return try copyToBuf(buf, self.event.utf8); + } + // If we're reporting all then we always send CSI sequences. if (!self.kitty_flags.report_all) { // Quote: @@ -1177,6 +1186,25 @@ test "kitty: alternates omit control characters" { try testing.expectEqualStrings("\x1b[3~", actual); } +test "kitty: enter with utf8 (dead key state)" { + var buf: [128]u8 = undefined; + var enc: KeyEncoder = .{ + .event = .{ + .key = .enter, + .utf8 = "A", + .unshifted_codepoint = 0x0D, + }, + .kitty_flags = .{ + .disambiguate = true, + .report_alternates = true, + .report_all = true, + }, + }; + + const actual = try enc.kitty(&buf); + try testing.expectEqualStrings("A", actual); +} + test "legacy: enter with utf8 (dead key state)" { var buf: [128]u8 = undefined; var enc: KeyEncoder = .{