summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-02 22:25:35 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-02 22:25:35 +0200
commit04d594b9c14299ed50da0774fb8d3a10fbc4076f (patch)
tree3aba97a163925267ee60a6832bf74f632c934f8a
parent6c553f9c04a698ac2e19584f8ea8e2cb7cd98c80 (diff)
downloadvim-git-04d594b9c14299ed50da0774fb8d3a10fbc4076f.tar.gz
patch 8.2.1577: Vim9: hasmapto()/mapcheck()/maparg() do nottake "true" argv8.2.1577
Problem: Vim9: hasmapto(), mapcheck() and maparg() do not take "true" as argument. Solution: Use tv_get_bool(). (closes #6822, closes #6824)
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/map.c4
-rw-r--r--src/testdir/test_vim9_func.vim39
-rw-r--r--src/version.c2
4 files changed, 44 insertions, 3 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 4f0bb5cea..91fbc675c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4808,7 +4808,7 @@ f_hasmapto(typval_T *argvars, typval_T *rettv)
{
mode = tv_get_string_buf(&argvars[1], buf);
if (argvars[2].v_type != VAR_UNKNOWN)
- abbr = (int)tv_get_number(&argvars[2]);
+ abbr = (int)tv_get_bool(&argvars[2]);
}
if (map_to_exists(name, mode, abbr))
diff --git a/src/map.c b/src/map.c
index dd3139dcd..eed3a55d0 100644
--- a/src/map.c
+++ b/src/map.c
@@ -2204,9 +2204,9 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
which = tv_get_string_buf_chk(&argvars[1], buf);
if (argvars[2].v_type != VAR_UNKNOWN)
{
- abbr = (int)tv_get_number(&argvars[2]);
+ abbr = (int)tv_get_bool(&argvars[2]);
if (argvars[3].v_type != VAR_UNKNOWN)
- get_dict = (int)tv_get_number(&argvars[3]);
+ get_dict = (int)tv_get_bool(&argvars[3]);
}
}
else
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 04f8d7aa7..f79c2e0bd 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1521,6 +1521,45 @@ def Test_globpath()
assert_equal(['./runtest.vim'], globpath('.', 'runtest.vim', true, true, true))
enddef
+def Test_hasmapto()
+ assert_equal(0, hasmapto('foobar', 'i', true))
+ iabbrev foo foobar
+ assert_equal(1, hasmapto('foobar', 'i', true))
+ iunabbrev foo
+enddef
+
+def SID(): number
+ return expand('<SID>')
+ ->matchstr('<SNR>\zs\d\+\ze_$')
+ ->str2nr()
+enddef
+
+def Test_maparg()
+ let lnum = str2nr(expand('<sflnum>'))
+ map foo bar
+ assert_equal(#{
+ lnum: lnum + 1,
+ script: 0,
+ mode: ' ',
+ silent: 0,
+ noremap: 0,
+ lhs: 'foo',
+ lhsraw: 'foo',
+ nowait: 0,
+ expr: 0,
+ sid: SID(),
+ rhs: 'bar',
+ buffer: 0},
+ maparg('foo', '', false, true))
+ unmap foo
+enddef
+
+def Test_mapcheck()
+ iabbrev foo foobar
+ assert_equal('foobar', mapcheck('foo', 'i', true))
+ iunabbrev foo
+enddef
+
def Test_recursive_call()
assert_equal(6765, Fibonacci(20))
enddef
diff --git a/src/version.c b/src/version.c
index 388be57e3..5232e8485 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1577,
+/**/
1576,
/**/
1575,