From 99abff85dd0e1e74d61d2c1777108e86d364ae66 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 21 Aug 2023 08:10:27 -0700 Subject: [PATCH] input: pc style function keys should use all mods, not effective --- src/input/KeyEncoder.zig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index ac94f0b04..43b2deac3 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -171,7 +171,7 @@ fn legacy( // If we match a PC style function key then that is our result. if (pcStyleFunctionKey( self.event.key, - binding_mods, + all_mods, self.cursor_key_application, self.keypad_key_application, self.modify_other_keys_state_2, @@ -948,6 +948,20 @@ test "legacy: fixterm awkward letters" { } } +test "legacy: shift+function key should use all mods" { + var buf: [128]u8 = undefined; + var enc: KeyEncoder = .{ + .event = .{ + .key = .up, + .mods = .{ .shift = true }, + .consumed_mods = .{ .shift = true }, + }, + }; + + const actual = try enc.legacy(&buf); + try testing.expectEqualStrings("\x1b[1;2A", actual); +} + test "ctrlseq: normal ctrl c" { const seq = ctrlSeq(.c, .{ .ctrl = true }); try testing.expectEqual(@as(u8, 0x03), seq.?);