Skip to content

Commit f88a5bc

Browse files
committed
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Problem: maparg() and mapcheck() confuse empty and non-existing. Solution: Return <Nop> for an existing non-empty mapping. (closes #2940)
1 parent 6bff719 commit f88a5bc

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/evalfunc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7383,7 +7383,12 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
73837383
{
73847384
/* Return a string. */
73857385
if (rhs != NULL)
7386-
rettv->vval.v_string = str2special_save(rhs, FALSE);
7386+
{
7387+
if (*rhs == NUL)
7388+
rettv->vval.v_string = vim_strsave((char_u *)"<Nop>");
7389+
else
7390+
rettv->vval.v_string = str2special_save(rhs, FALSE);
7391+
}
73877392

73887393
}
73897394
else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL)

src/testdir/test_maparg.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ function Test_maparg()
2929
\ maparg('foo', '', 0, 1))
3030

3131
map abc x<char-114>x
32-
call assert_equal(maparg('abc'), "xrx")
32+
call assert_equal("xrx", maparg('abc'))
3333
map abc y<S-char-114>y
34-
call assert_equal(maparg('abc'), "yRy")
34+
call assert_equal("yRy", maparg('abc'))
35+
36+
map abc <Nop>
37+
call assert_equal("<Nop>", maparg('abc'))
38+
unmap abc
3539
endfunction
3640

3741
function Test_range_map()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
11,
764766
/**/
765767
10,
766768
/**/

0 commit comments

Comments
 (0)