changeset 19870:658248b68f7c v8.2.0491

patch 8.2.0491: cannot recognize a <script> mapping using maparg() Commit: https://github.com/vim/vim/commit/2da0f0c445da3c9b35b2a0cd595d10e81ad2a6f9 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 1 19:22:12 2020 +0200 patch 8.2.0491: cannot recognize a <script> mapping using maparg() Problem: Cannot recognize a <script> mapping using maparg(). Solution: Add the "script" key. (closes https://github.com/vim/vim/issues/5873)
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Apr 2020 19:30:04 +0200
parents 8c8c7c532424
children 7f8a267721e4
files runtime/doc/eval.txt src/map.c src/testdir/test_maparg.vim src/version.c
diffstat 4 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6824,6 +6824,7 @@ maparg({name} [, {mode} [, {abbr} [, {di
 		  "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
--- a/src/map.c
+++ b/src/map.c
@@ -2200,6 +2200,8 @@ get_maparg(typval_T *argvars, typval_T *
 	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);
--- 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))
--- 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,