mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
input: do not encode enter with utf8 as pc style key
If the enter key has utf-8 attach, we assume its a dead key state being committed so we don't process it.
This commit is contained in:
@ -204,7 +204,16 @@ fn legacy(
|
||||
self.cursor_key_application,
|
||||
self.keypad_key_application,
|
||||
self.modify_other_keys_state_2,
|
||||
)) |sequence| return copyToBuf(buf, sequence);
|
||||
)) |sequence| pc_style: {
|
||||
// If we're pressing enter and have UTF-8 text, we probably are
|
||||
// clearing a dead key state. This happens specifically on macOS.
|
||||
// We have a unit test for this.
|
||||
if (self.event.key == .enter and self.event.utf8.len > 0) {
|
||||
break :pc_style;
|
||||
}
|
||||
|
||||
return copyToBuf(buf, sequence);
|
||||
}
|
||||
|
||||
// If we match a control sequence, we output that directly. For
|
||||
// ctrlSeq we have to use all mods because we want it to only
|
||||
@ -1168,6 +1177,20 @@ test "kitty: alternates omit control characters" {
|
||||
try testing.expectEqualStrings("\x1b[3~", actual);
|
||||
}
|
||||
|
||||
test "legacy: enter with utf8 (dead key state)" {
|
||||
var buf: [128]u8 = undefined;
|
||||
var enc: KeyEncoder = .{
|
||||
.event = .{
|
||||
.key = .enter,
|
||||
.utf8 = "A",
|
||||
.unshifted_codepoint = 0x0D,
|
||||
},
|
||||
};
|
||||
|
||||
const actual = try enc.legacy(&buf);
|
||||
try testing.expectEqualStrings("A", actual);
|
||||
}
|
||||
|
||||
test "legacy: ctrl+alt+c" {
|
||||
var buf: [128]u8 = undefined;
|
||||
var enc: KeyEncoder = .{
|
||||
|
Reference in New Issue
Block a user