]> granicus.if.org Git - vim/commitdiff
patch 8.2.4819: unmapping simplified keys also deletes other mapping v8.2.4819
authorzeertzjq <zeertzjq@outlook.com>
Sun, 24 Apr 2022 16:07:53 +0000 (17:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 24 Apr 2022 16:07:53 +0000 (17:07 +0100)
Problem:    Unmapping simplified keys also deletes other mapping.
Solution:   Only unmap a mapping with m_simplified set. (closes #10270)

src/map.c
src/testdir/test_mapping.vim
src/version.c

index d99a84fc398226e9ab5f10a77cb635b23204484e..f3ff00729b2296f3db72204bd4fe798ff999dd0d 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -725,6 +725,9 @@ do_map(
                                    mpp = &(mp->m_next);
                                    continue;
                                }
+                               if (did_simplify && keyround == 1
+                                                         && !mp->m_simplified)
+                                   break;
                                // We reset the indicated mode bits. If nothing
                                // is left the entry is deleted below.
                                mp->m_mode &= ~mode;
@@ -814,7 +817,10 @@ do_map(
        {
            // delete entry
            if (!did_it)
-               retval = 2;     // no match
+           {
+               if (!did_simplify || keyround == 2)
+                   retval = 2;         // no match
+           }
            else if (*keys == Ctrl_C)
            {
                // If CTRL-C has been unmapped, reuse it for Interrupting.
index 7fdbdf6184b8739b9fe3d20b754990c38e487cd5..e0008d62a272a8781af126053f65b01b2ba9fe11 100644 (file)
@@ -1627,4 +1627,15 @@ func Test_mouse_drag_insert_map()
   set mouse&
 endfunc
 
+func Test_unmap_simplfied()
+  map <C-I> foo
+  map <Tab> bar
+  call assert_equal('foo', maparg('<C-I>'))
+  call assert_equal('bar', maparg('<Tab>'))
+  unmap <C-I>
+  call assert_equal('', maparg('<C-I>'))
+  call assert_equal('bar', maparg('<Tab>'))
+  unmap <Tab>
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 74b4625eb04863f3e6b7b7c2a51b9bae3763ccf2..1d54137bf9f1f80ce1921808cf6f89898b77fd22 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4819,
 /**/
     4818,
 /**/