summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-01 19:22:12 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-01 19:22:12 +0200
commit2da0f0c445da3c9b35b2a0cd595d10e81ad2a6f9 (patch)
treede42f08bbd29bad7e82f85da46d4fa546e0304df
parent0afdcf8601792ee751984265b49fc2ca6f8ea858 (diff)
downloadvim-git-8.2.0491.tar.gz
patch 8.2.0491: cannot recognize a <script> mapping using maparg()v8.2.0491
Problem: Cannot recognize a <script> mapping using maparg(). Solution: Add the "script" key. (closes #5873)
-rw-r--r--runtime/doc/eval.txt1
-rw-r--r--src/map.c2
-rw-r--r--src/testdir/test_maparg.vim8
-rw-r--r--src/version.c2
4 files changed, 9 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 45ef83ada..74c3d1cfa 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6824,6 +6824,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
"rhs" The {rhs} of the mapping as typed.
"silent" 1 for a |:map-silent| mapping, else 0.
"noremap" 1 if the {rhs} of the mapping is not remappable.
+ "script" 1 if mapping was defined with <script>.
"expr" 1 for an expression mapping (|:map-<expr>|).
"buffer" 1 for a buffer local mapping (|:map-local|).
"mode" Modes for which the mapping is defined. In
diff --git a/src/map.c b/src/map.c
index 948b32cc6..9bc9abca3 100644
--- a/src/map.c
+++ b/src/map.c
@@ -2200,6 +2200,8 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
dict_add_string(dict, "lhs", lhs);
dict_add_string(dict, "rhs", mp->m_orig_str);
dict_add_number(dict, "noremap", mp->m_noremap ? 1L : 0L);
+ dict_add_number(dict, "script", mp->m_noremap == REMAP_SCRIPT
+ ? 1L : 0L);
dict_add_number(dict, "expr", mp->m_expr ? 1L : 0L);
dict_add_number(dict, "silent", mp->m_silent ? 1L : 0L);
dict_add_number(dict, "sid", (long)mp->m_script_ctx.sc_sid);
diff --git a/src/testdir/test_maparg.vim b/src/testdir/test_maparg.vim
index d6b61019b..cc72e7e8e 100644
--- a/src/testdir/test_maparg.vim
+++ b/src/testdir/test_maparg.vim
@@ -16,23 +16,23 @@ function Test_maparg()
map foo<C-V> is<F4>foo
vnoremap <script> <buffer> <expr> <silent> bar isbar
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
\ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
\ 'rhs': 'is<F4>foo', 'buffer': 0},
\ maparg('foo<C-V>', '', 0, 1))
- call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v',
+ call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v',
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
\ 'rhs': 'isbar', 'buffer': 1},
\ 'bar'->maparg('', 0, 1))
let lnum = expand('<sflnum>')
map <buffer> <nowait> foo bar
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ',
\ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
\ 'buffer': 1},
\ maparg('foo', '', 0, 1))
let lnum = expand('<sflnum>')
tmap baz foo
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'baz', 'mode': 't',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', 'mode': 't',
\ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
\ 'buffer': 0},
\ maparg('baz', 't', 0, 1))
diff --git a/src/version.c b/src/version.c
index 035372077..31f2f74bf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 491,
+/**/
490,
/**/
489,