]> granicus.if.org Git - vim/commitdiff
patch 8.1.2142: some key mappings do not work with modifyOtherKeys v8.1.2142
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Oct 2019 16:22:50 +0000 (18:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Oct 2019 16:22:50 +0000 (18:22 +0200)
Problem:    Some key mappings do not work with modifyOtherKeys.
Solution:   Remove the Shift modifier if it is already included in the key.

src/term.c
src/testdir/test_termcodes.vim
src/version.c

index 27def15c6a450566c3845bdca784cbf9cc9e4e8e..e30506bc427a7486368d0f3480479a6c2768db64 100644 (file)
@@ -4847,8 +4847,17 @@ not_enough:
                    else
                        key = arg[2];
 
-                   // insert modifiers with KS_MODIFIER
                    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
                    new_slen = modifiers2keycode(modifiers, &key, string);
                    slen = csi_len;
 
index 0d157aeb42e9d56476a57c3ac33e9fda64964ac8..1df9f7bf118115e54e9e5bf95220ce6232cb0260 100644 (file)
@@ -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) .. "\<Esc>", '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
index c92eb26a10a050ca47e0b32cfd6caf89f44f7f1a..74126d2e24d09d7839b6a57b68fc8ef679fcacf0 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2142,
 /**/
     2141,
 /**/