]> granicus.if.org Git - vim/commitdiff
patch 8.2.0491: cannot recognize a <script> mapping using maparg() v8.2.0491
authorBram Moolenaar <Bram@vim.org>
Wed, 1 Apr 2020 17:22:12 +0000 (19:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 1 Apr 2020 17:22:12 +0000 (19:22 +0200)
Problem:    Cannot recognize a <script> mapping using maparg().
Solution:   Add the "script" key. (closes #5873)

runtime/doc/eval.txt
src/map.c
src/testdir/test_maparg.vim
src/version.c

index 45ef83ada2615376a9dab918f8df681798f1b52a..74c3d1cfa0cda9754659c9f5073285d425e9e0a1 100644 (file)
@@ -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
index 948b32cc6ce959ebc1b80d8e846c4931e837f4e9..9bc9abca3aae705d0fd0a60e89df8366e71b662a 100644 (file)
--- 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);
index d6b61019bb853af9855321ede4d1913fb57a5b98..cc72e7e8e65f4ea71bc595b5b0dfad8bfc853406 100644 (file)
@@ -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))
index 0353720775869117ecf4ab761a9d83840c7b6ecd..31f2f74bf876b93a75159ca3576944395e3a03c5 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    491,
 /**/
     490,
 /**/