To: vim_dev@googlegroups.com Subject: Patch 9.0.0973 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.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) Files: src/term.c, src/testdir/test_termcodes.vim *** ../vim-9.0.0972/src/term.c 2022-11-29 16:09:14.408617365 +0000 --- src/term.c 2022-11-29 18:27:41.454043629 +0000 *************** *** 4693,4698 **** --- 4693,4700 ---- modifiers |= MOD_MASK_CTRL; if (code & 8) modifiers |= MOD_MASK_META; + // Any further modifiers are silently dropped. + return modifiers; } *************** *** 5317,5330 **** // 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 == '~') || (argc == 2 && trail == 'u')) - && arg[1] <= 16) { return len + handle_key_with_modifier(arg, trail, ! csi_len, offset, buf, bufsize, buflen); } // Key without modifier (Kitty sends this for Esc): --- 5319,5332 ---- // Key with modifier: // {lead}27;{modifier};{key}~ // {lead}{key};{modifier}u ! // 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')) { return len + handle_key_with_modifier(arg, trail, ! csi_len, offset, buf, bufsize, buflen); } // Key without modifier (Kitty sends this for Esc): *** ../vim-9.0.0972/src/testdir/test_termcodes.vim 2022-11-27 12:45:37.311707363 +0000 --- src/testdir/test_termcodes.vim 2022-11-29 18:30:42.781485105 +0000 *************** *** 2459,2464 **** --- 2459,2488 ---- 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('', 'z', Func, 5) + " Add 16, 32, 64 or 128 for modifiers we currently don't support. + call RunTest_mapping_mods('', 'z', Func, 5 + 16) + call RunTest_mapping_mods('', 'z', Func, 5 + 32) + call RunTest_mapping_mods('', 'z', Func, 5 + 64) + call RunTest_mapping_mods('', 'z', Func, 5 + 128) + + call RunTest_mapping_mods('', 'X', Func, 2) + " Add 16, 32, 64 or 128 for modifiers we currently don't support. + call RunTest_mapping_mods('', 'X', Func, 2 + 16) + call RunTest_mapping_mods('', 'X', Func, 2 + 32) + call RunTest_mapping_mods('', 'X', Func, 2 + 64) + call RunTest_mapping_mods('', 'X', Func, 2 + 128) + endfor + + bwipe! + set timeoutlen& + endfunc + func Test_insert_literal() set timeoutlen=10 *** ../vim-9.0.0972/src/version.c 2022-11-29 16:09:14.408617365 +0000 --- src/version.c 2022-11-29 18:01:25.518308540 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 973, /**/ -- hundred-and-one symptoms of being an internet addict: 177. You log off of your system because it's time to go to work. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///