# HG changeset patch # User Bram Moolenaar # Date 1604159103 -3600 # Node ID d03221aa54f3b984d99aedc3fb6066993bf6578c # Parent af49741c66b4e157324848d6871a1a671e822b48 patch 8.2.1930: wrong input if removing shift results in special key code Commit: https://github.com/vim/vim/commit/749bc9521d9c1b3b3250faef25a3710206cf277d Author: Bram Moolenaar Date: Sat Oct 31 16:33:47 2020 +0100 patch 8.2.1930: wrong input if removing shift results in special key code Problem: Wrong input if removing shift results in special key code. Solution: Handle special key codes. (closes https://github.com/vim/vim/issues/7189) diff --git a/src/term.c b/src/term.c --- a/src/term.c +++ b/src/term.c @@ -4462,7 +4462,8 @@ modifiers2keycode(int modifiers, int *ke if (modifiers != 0) { // Some keys have the modifier included. Need to handle that here to - // make mappings work. + // make mappings work. This may result in a special key, such as + // K_S_TAB. *key = simplify_key(*key, &modifiers); if (modifiers != 0) { @@ -4793,7 +4794,13 @@ handle_key_with_modifier( // insert modifiers with KS_MODIFIER new_slen = modifiers2keycode(modifiers, &key, string); - if (has_mbyte) + if (IS_SPECIAL(key)) + { + string[new_slen++] = K_SPECIAL; + string[new_slen++] = KEY2TERMCAP0(key); + string[new_slen++] = KEY2TERMCAP1(key); + } + else if (has_mbyte) new_slen += (*mb_char2bytes)(key, string + new_slen); else string[new_slen++] = key; diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -2029,6 +2029,23 @@ func Test_modifyOtherKeys_mapped() set timeoutlen& endfunc +" Whether Shift-Tab sends "ESC [ Z" or "ESC [ 27 ; 2 ; 9 ~" is unpredictable, +" both should work. +func Test_modifyOtherKeys_shift_tab() + set timeoutlen=10 + + call setline(1, '') + call feedkeys("a\" .. GetEscCodeCSI27("\t", '2') .. "\", 'Lx!') + eval getline(1)->assert_equal('') + + call setline(1, '') + call feedkeys("a\\[Z\", 'Lx!') + eval getline(1)->assert_equal('') + + set timeoutlen& + bwipe! +endfunc + func RunTest_mapping_works_with_shift(func) new set timeoutlen=10 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1930, +/**/ 1929, /**/ 1928,