]> granicus.if.org Git - vim/commitdiff
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing v8.1.0011
authorBram Moolenaar <Bram@vim.org>
Mon, 21 May 2018 11:28:44 +0000 (13:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 May 2018 11:28:44 +0000 (13:28 +0200)
Problem:    maparg() and mapcheck() confuse empty and non-existing.
Solution:   Return <Nop> for an existing non-empty mapping. (closes #2940)

src/evalfunc.c
src/testdir/test_maparg.vim
src/version.c

index 5cee976d357886d6b66cd1b3075f93d50e82e535..46e55b3fd202eb08eca16fc46ec1a0f15f8d2559 100644 (file)
@@ -7383,7 +7383,12 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
     {
        /* Return a string. */
        if (rhs != NULL)
-           rettv->vval.v_string = str2special_save(rhs, FALSE);
+       {
+           if (*rhs == NUL)
+               rettv->vval.v_string = vim_strsave((char_u *)"<Nop>");
+           else
+               rettv->vval.v_string = str2special_save(rhs, FALSE);
+       }
 
     }
     else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL)
index 9ad83836c656f640da7649ae29e851868fcc4043..0fb878b04a62a82c6cf5ad7a9fe7779d989fc114 100644 (file)
@@ -29,9 +29,13 @@ function Test_maparg()
         \ maparg('foo', '', 0, 1))
 
   map abc x<char-114>x
-  call assert_equal(maparg('abc'), "xrx")
+  call assert_equal("xrx", maparg('abc'))
   map abc y<S-char-114>y
-  call assert_equal(maparg('abc'), "yRy")
+  call assert_equal("yRy", maparg('abc'))
+
+  map abc <Nop>
+  call assert_equal("<Nop>", maparg('abc'))
+  unmap abc
 endfunction
 
 function Test_range_map()
index 7cf8d16b9bf16ecf153e19861e56756e355420f3..3ebeb772ddf1094390ff97d000610e8f78e795d2 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    11,
 /**/
     10,
 /**/