Skip to content

Commit 41fff92

Browse files
nowaymyname27rockorager
authored andcommitted
fix(parser): parse CSI Z as shift+tab
1 parent a3ae1d5 commit 41fff92

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/Parser.zig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,17 @@ inline fn parseCsi(input: []const u8, text_buf: []u8) Result {
403403
.n = sequence.len,
404404
};
405405
},
406+
'Z' => {
407+
// Legacy keys
408+
// CSI Z
409+
return .{
410+
.event = .{ .key_press = .{
411+
.codepoint = Key.tab,
412+
.mods = .{ .shift = true },
413+
} },
414+
.n = sequence.len,
415+
};
416+
},
406417
'~' => {
407418
// Legacy keys
408419
// CSI number ~
@@ -855,6 +866,18 @@ test "parse: xterm shift+up" {
855866
try testing.expectEqual(expected_event, result.event);
856867
}
857868

869+
test "parse: xterm shift+tab" {
870+
const alloc = testing.allocator_instance.allocator();
871+
const input = "\x1b[Z";
872+
var parser: Parser = .{};
873+
const result = try parser.parse(input, alloc);
874+
const expected_key: Key = .{ .codepoint = Key.tab, .mods = .{ .shift = true } };
875+
const expected_event: Event = .{ .key_press = expected_key };
876+
877+
try testing.expectEqual(3, result.n);
878+
try testing.expectEqual(expected_event, result.event);
879+
}
880+
858881
test "parse: xterm insert" {
859882
const alloc = testing.allocator_instance.allocator();
860883
const input = "\x1b[2~";

0 commit comments

Comments
 (0)