diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-11-29 18:32:32 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-11-29 18:32:32 +0000 |
commit | 064fd67e6a0283bb24732146fd20c92b6dbf47bf (patch) | |
tree | bd178c620a22aa5d6cea9b0555fc916eda2b4b63 | |
parent | 4e6072b8d3e7ad85d2ca010c9172c2bdcdc62f44 (diff) | |
download | vim-git-064fd67e6a0283bb24732146fd20c92b6dbf47bf.tar.gz |
patch 9.0.0973: Kitty keyboard protocol key with NumLock not decodedv9.0.0973
Problem: Kitty keyboard protocol key not decoded when it has an unsupported
modifier, such as NumLock.
Solution: Accept a key with any modifier. (closes #11638)
-rw-r--r-- | src/term.c | 12 | ||||
-rw-r--r-- | src/testdir/test_termcodes.vim | 24 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/term.c b/src/term.c index 810fae998..ba288ae8b 100644 --- a/src/term.c +++ b/src/term.c @@ -4693,6 +4693,8 @@ decode_modifiers(int n) modifiers |= MOD_MASK_CTRL; if (code & 8) modifiers |= MOD_MASK_META; + // Any further modifiers are silently dropped. + return modifiers; } @@ -5317,14 +5319,14 @@ handle_csi( // Key with modifier: // {lead}27;{modifier};{key}~ // {lead}{key};{modifier}u - // Only handles four modifiers, this won't work if the modifier value is - // more than 16. - else if (((arg[0] == 27 && argc == 3 && trail == '~') + // Even though we only handle four modifiers and the {modifier} value + // should be 16 or lower, we accept all modifier values to avoid the raw + // sequence to be passed through. + else if ((arg[0] == 27 && argc == 3 && trail == '~') || (argc == 2 && trail == 'u')) - && arg[1] <= 16) { return len + handle_key_with_modifier(arg, trail, - csi_len, offset, buf, bufsize, buflen); + csi_len, offset, buf, bufsize, buflen); } // Key without modifier (Kitty sends this for Esc): diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim index 690a3f78e..eb3023014 100644 --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -2459,6 +2459,30 @@ func Test_mapping_works_with_shift_ctrl_alt() call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-S-A', 8) endfunc +func Test_mapping_works_with_unknown_modifiers() + new + set timeoutlen=10 + + for Func in [function('GetEscCodeCSI27'), function('GetEscCodeCSIu')] + call RunTest_mapping_mods('<C-z>', 'z', Func, 5) + " Add 16, 32, 64 or 128 for modifiers we currently don't support. + call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 16) + call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 32) + call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 64) + call RunTest_mapping_mods('<C-z>', 'z', Func, 5 + 128) + + call RunTest_mapping_mods('<S-X>', 'X', Func, 2) + " Add 16, 32, 64 or 128 for modifiers we currently don't support. + call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 16) + call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 32) + call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 64) + call RunTest_mapping_mods('<S-X>', 'X', Func, 2 + 128) + endfor + + bwipe! + set timeoutlen& +endfunc + func Test_insert_literal() set timeoutlen=10 diff --git a/src/version.c b/src/version.c index e41b1062a..8a646722f 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 973, +/**/ 972, /**/ 971, |