summaryrefslogtreecommitdiff
path: root/src/input/KeyEncoder.zig
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2023-11-24 07:58:31 -0800
committerMitchell Hashimoto <mitchell.hashimoto@gmail.com>2023-11-24 07:58:31 -0800
commita67d90710c2db9d032502cd4688d55ca00697b60 (patch)
treeee11050becd927ec95cae7e5c207e10f34863f1e /src/input/KeyEncoder.zig
parentbf30c38945ed7793ef83fe97285faf87cc3d1445 (diff)
input: kitty encoding should ignore committed preedit state
Fixes #952
Diffstat (limited to 'src/input/KeyEncoder.zig')
-rw-r--r--src/input/KeyEncoder.zig28
1 files changed, 28 insertions, 0 deletions
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 = .{