# HG changeset patch # User Bram Moolenaar # Date 1570897804 -7200 # Node ID 43e9523f6d84d7092fd54f6b16738ccbd4bee64c # Parent 98c9b8a53e77b49feed3b9591e004148b348e01e patch 8.1.2142: some key mappings do not work with modifyOtherKeys Commit: https://github.com/vim/vim/commit/d1e2f3984ae0b4e22ba6977eedcf05285819eea9 Author: Bram Moolenaar Date: Sat Oct 12 18:22:50 2019 +0200 patch 8.1.2142: some key mappings do not work with modifyOtherKeys Problem: Some key mappings do not work with modifyOtherKeys. Solution: Remove the Shift modifier if it is already included in the key. diff --git a/src/term.c b/src/term.c --- a/src/term.c +++ b/src/term.c @@ -4847,8 +4847,17 @@ not_enough: else key = arg[2]; + modifiers = decode_modifiers(arg[1]); + + // Some keys already have Shift included, pass them as + // normal keys. + if (modifiers == MOD_MASK_SHIFT + && ((key >= '@' && key <= 'Z') + || key == '^' || key == '_' + || (key >= '{' && key <= '~'))) + modifiers = 0; + // insert modifiers with KS_MODIFIER - modifiers = decode_modifiers(arg[1]); new_slen = modifiers2keycode(modifiers, &key, string); slen = csi_len; 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 @@ -909,3 +909,42 @@ endfunc func Test_modifyOtherKeys_CSIu() call RunTest_modifyOtherKeys(function('GetEscCodeCSIu')) endfunc + +func RunTest_mapping_shift(key, func) + call setline(1, '') + if a:key == '|' + exe 'inoremap \| xyz' + else + exe 'inoremap ' .. a:key .. ' xyz' + endif + call feedkeys('a' .. a:func(a:key, 2) .. "\", 'Lx!') + call assert_equal("xyz", getline(1)) + if a:key == '|' + exe 'iunmap \|' + else + exe 'iunmap ' .. a:key + endif +endfunc + +func RunTest_mapping_works_with_shift(func) + new + set timeoutlen=20 + + call RunTest_mapping_shift('@', a:func) + call RunTest_mapping_shift('A', a:func) + call RunTest_mapping_shift('Z', a:func) + call RunTest_mapping_shift('^', a:func) + call RunTest_mapping_shift('_', a:func) + call RunTest_mapping_shift('{', a:func) + call RunTest_mapping_shift('|', a:func) + call RunTest_mapping_shift('}', a:func) + call RunTest_mapping_shift('~', a:func) + + bwipe! + set timeoutlen& +endfunc + +func Test_mapping_works_with_shift() + call RunTest_mapping_works_with_shift(function('GetEscCodeCSI27')) + call RunTest_mapping_works_with_shift(function('GetEscCodeCSIu')) +endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2142, +/**/ 2141, /**/ 2140,