Skip to content

Commit 04d594b

Browse files
committed
patch 8.2.1577: Vim9: hasmapto()/mapcheck()/maparg() do nottake "true" arg
Problem: Vim9: hasmapto(), mapcheck() and maparg() do not take "true" as argument. Solution: Use tv_get_bool(). (closes #6822, closes #6824)
1 parent 6c553f9 commit 04d594b

4 files changed

Lines changed: 44 additions & 3 deletions

File tree

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4808,7 +4808,7 @@ f_hasmapto(typval_T *argvars, typval_T *rettv)
48084808
{
48094809
mode = tv_get_string_buf(&argvars[1], buf);
48104810
if (argvars[2].v_type != VAR_UNKNOWN)
4811-
abbr = (int)tv_get_number(&argvars[2]);
4811+
abbr = (int)tv_get_bool(&argvars[2]);
48124812
}
48134813

48144814
if (map_to_exists(name, mode, abbr))

src/map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,9 +2204,9 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
22042204
which = tv_get_string_buf_chk(&argvars[1], buf);
22052205
if (argvars[2].v_type != VAR_UNKNOWN)
22062206
{
2207-
abbr = (int)tv_get_number(&argvars[2]);
2207+
abbr = (int)tv_get_bool(&argvars[2]);
22082208
if (argvars[3].v_type != VAR_UNKNOWN)
2209-
get_dict = (int)tv_get_number(&argvars[3]);
2209+
get_dict = (int)tv_get_bool(&argvars[3]);
22102210
}
22112211
}
22122212
else

src/testdir/test_vim9_func.vim

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,45 @@ def Test_globpath()
15211521
assert_equal(['./runtest.vim'], globpath('.', 'runtest.vim', true, true, true))
15221522
enddef
15231523

1524+
def Test_hasmapto()
1525+
assert_equal(0, hasmapto('foobar', 'i', true))
1526+
iabbrev foo foobar
1527+
assert_equal(1, hasmapto('foobar', 'i', true))
1528+
iunabbrev foo
1529+
enddef
1530+
1531+
def SID(): number
1532+
return expand('<SID>')
1533+
->matchstr('<SNR>\zs\d\+\ze_$')
1534+
->str2nr()
1535+
enddef
1536+
1537+
def Test_maparg()
1538+
let lnum = str2nr(expand('<sflnum>'))
1539+
map foo bar
1540+
assert_equal(#{
1541+
lnum: lnum + 1,
1542+
script: 0,
1543+
mode: ' ',
1544+
silent: 0,
1545+
noremap: 0,
1546+
lhs: 'foo',
1547+
lhsraw: 'foo',
1548+
nowait: 0,
1549+
expr: 0,
1550+
sid: SID(),
1551+
rhs: 'bar',
1552+
buffer: 0},
1553+
maparg('foo', '', false, true))
1554+
unmap foo
1555+
enddef
1556+
1557+
def Test_mapcheck()
1558+
iabbrev foo foobar
1559+
assert_equal('foobar', mapcheck('foo', 'i', true))
1560+
iunabbrev foo
1561+
enddef
1562+
15241563
def Test_recursive_call()
15251564
assert_equal(6765, Fibonacci(20))
15261565
enddef

src/version.c

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

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1577,
757759
/**/
758760
1576,
759761
/**/

0 commit comments

Comments
 (0)