]> granicus.if.org Git - vim/commitdiff
patch 8.2.4504: when there is a partially matching map full map may not work v8.2.4504
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Mar 2022 19:22:36 +0000 (19:22 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Mar 2022 19:22:36 +0000 (19:22 +0000)
Problem:    When there is a partially matching map and modifyOtherKeys is
            active a full map may not work.
Solution:   Only simplify modifiers when there is no matching mapping.
            (closes #8792)

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

index 2fbbd4f6e1255826ff0f26018f16c72bad5a4eda..03d6d4d96d333ee8f8312e3206a807c04d7544a4 100644 (file)
@@ -2598,7 +2598,7 @@ handle_mapping(
        }
 
        // If no partly match found, use the longest full match.
-       if (keylen != KEYLEN_PART_MAP)
+       if (keylen != KEYLEN_PART_MAP && mp_match != NULL)
        {
            mp = mp_match;
            keylen = mp_match_len;
@@ -2643,7 +2643,7 @@ handle_mapping(
            max_mlen = mlen + 1;
     }
 
-    if ((mp == NULL || max_mlen >= mp_match_len) && keylen != KEYLEN_PART_MAP)
+    if ((mp == NULL || max_mlen > mp_match_len) && keylen != KEYLEN_PART_MAP)
     {
        int     save_keylen = keylen;
 
index 614c0977d7e887411b14f6e06e0bd6f35956eacf..a68506c1e6b526fea8904e22d97bbc33e1b77aed 100644 (file)
@@ -2098,6 +2098,23 @@ func Test_modifyOtherKeys_mapped()
   set timeoutlen&
 endfunc
 
+func Test_modifyOtherKeys_ambiguous_mapping()
+  new
+  set timeoutlen=10
+  map <C-J> a
+  map <C-J>x <Nop>
+  call setline(1, 'x')
+
+  " CTRL-J b should have trigger the <C-J> mapping and then insert "b"
+  call feedkeys(GetEscCodeCSI27('J', 5) .. "b\<Esc>", 'Lx!')
+  call assert_equal('xb', getline(1))
+
+  unmap <C-J>
+  unmap <C-J>x
+  set timeoutlen&
+  bwipe!
+endfunc
+
 " Whether Shift-Tab sends "ESC [ Z" or "ESC [ 27 ; 2 ; 9 ~" is unpredictable,
 " both should work.
 func Test_modifyOtherKeys_shift_tab()
index 6a21b8a9a49a454128da239493e1ae78da88a2f1..e1ca0d7e8ff7e93d927ec8a440f56243fba4f998 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4504,
 /**/
     4503,
 /**/