Patch 8.2.4140
Problem: maparg() does not indicate the type of script where it was defined.
Solution: Add "scriptversion".
Files: runtime/doc/builtin.txt, src/map.c, src/testdir/test_maparg.vim
*** ../vim-8.2.4139/runtime/doc/builtin.txt 2022-01-16 13:30:29.877688041
+0000
--- runtime/doc/builtin.txt 2022-01-18 20:41:23.783201055 +0000
***************
*** 5243,5248 ****
--- 5247,5254 ----
(|mapmode-ic|)
"sid" The script local ID, used for <sid> mappings
(|<SID>|).
+ "scriptversion" The version of the script. 999999 for
+ |Vim9| script.
"lnum" The line number in "sid", zero if unknown.
"nowait" Do not wait for other, longer mappings.
(|:map-<nowait>|).
*** ../vim-8.2.4139/src/map.c 2022-01-18 20:30:31.404458472 +0000
--- src/map.c 2022-01-18 20:45:27.302878998 +0000
***************
*** 222,227 ****
--- 222,228 ----
#ifdef FEAT_EVAL
int expr,
scid_T sid, // -1 to use current_sctx
+ int scriptversion,
linenr_T lnum,
#endif
int simplified)
***************
*** 259,269 ****
mp->m_simplified = simplified;
#ifdef FEAT_EVAL
mp->m_expr = expr;
! if (sid >= 0)
{
mp->m_script_ctx.sc_sid = sid;
mp->m_script_ctx.sc_lnum = lnum;
! mp->m_script_ctx.sc_version = in_vim9script() ? SCRIPT_VERSION_VIM9 : 0;
}
else
{
--- 260,270 ----
mp->m_simplified = simplified;
#ifdef FEAT_EVAL
mp->m_expr = expr;
! if (sid > 0)
{
mp->m_script_ctx.sc_sid = sid;
mp->m_script_ctx.sc_lnum = lnum;
! mp->m_script_ctx.sc_version = scriptversion;
}
else
{
***************
*** 844,850 ****
if (map_add(map_table, abbr_table, keys, rhs, orig_rhs,
noremap, nowait, silent, mode, abbrev,
#ifdef FEAT_EVAL
! expr, /* sid */ -1, /* lnum */ 0,
#endif
did_simplify && keyround == 1) == FAIL)
{
--- 845,851 ----
if (map_add(map_table, abbr_table, keys, rhs, orig_rhs,
noremap, nowait, silent, mode, abbrev,
#ifdef FEAT_EVAL
! expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0,
#endif
did_simplify && keyround == 1) == FAIL)
{
***************
*** 2302,2307 ****
--- 2303,2310 ----
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);
+ dict_add_number(dict, "scriptversion",
+ (long)mp->m_script_ctx.sc_version);
dict_add_number(dict, "lnum", (long)mp->m_script_ctx.sc_lnum);
dict_add_number(dict, "buffer", (long)buffer_local);
dict_add_number(dict, "nowait", mp->m_nowait ? 1L : 0L);
***************
*** 2371,2376 ****
--- 2374,2380 ----
int silent;
int buffer;
scid_T sid;
+ int scriptversion;
linenr_T lnum;
mapblock_T **map_table = maphash;
mapblock_T **abbr_table = &first_abbr;
***************
*** 2416,2421 ****
--- 2420,2426 ----
expr = dict_get_number(d, (char_u *)"expr") != 0;
silent = dict_get_number(d, (char_u *)"silent") != 0;
sid = dict_get_number(d, (char_u *)"sid");
+ scriptversion = dict_get_number(d, (char_u *)"scriptversion");
lnum = dict_get_number(d, (char_u *)"lnum");
buffer = dict_get_number(d, (char_u *)"buffer");
nowait = dict_get_number(d, (char_u *)"nowait") != 0;
***************
*** 2446,2455 ****
vim_free(arg);
(void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap,
! nowait, silent, mode, is_abbr, expr, sid, lnum, 0);
if (lhsrawalt != NULL)
(void)map_add(map_table, abbr_table, lhsrawalt, rhs, orig_rhs, noremap,
! nowait, silent, mode, is_abbr, expr, sid, lnum, 1);
vim_free(keys_buf);
vim_free(arg_buf);
}
--- 2451,2461 ----
vim_free(arg);
(void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap,
! nowait, silent, mode, is_abbr, expr, sid, scriptversion, lnum, 0);
if (lhsrawalt != NULL)
(void)map_add(map_table, abbr_table, lhsrawalt, rhs, orig_rhs, noremap,
! nowait, silent, mode, is_abbr, expr, sid, scriptversion,
! lnum, 1);
vim_free(keys_buf);
vim_free(arg_buf);
}
*** ../vim-8.2.4139/src/testdir/test_maparg.vim 2021-04-24 12:12:32.230376646
+0100
--- src/testdir/test_maparg.vim 2022-01-18 20:49:01.338711408 +0000
***************
*** 18,43 ****
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs':
'foo<C-V>',
\ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16",
! \ '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, 'script': 1, 'lhs': 'bar',
\ 'lhsraw': '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, 'script': 0, 'lhs': 'foo',
\ 'lhsraw': '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, 'script': 0, 'lhs': 'baz',
\ 'lhsraw': 'baz', 'mode': 't',
! \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
\ 'buffer': 0},
\ maparg('baz', 't', 0, 1))
--- 18,47 ----
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs':
'foo<C-V>',
\ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16",
! \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
! \ 'lnum': lnum + 1,
\ 'rhs': 'is<F4>foo', 'buffer': 0},
\ maparg('foo<C-V>', '', 0, 1))
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar',
\ 'lhsraw': 'bar', 'mode': 'v',
! \ 'nowait': 0, 'expr': 1, 'sid': sid, 'scriptversion': 1,
! \ '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, 'script': 0, 'lhs': 'foo',
\ 'lhsraw': 'foo', 'mode': ' ',
! \ 'nowait': 1, 'expr': 0, 'sid': sid, 'scriptversion': 1,
! \ '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, 'script': 0, 'lhs': 'baz',
\ 'lhsraw': 'baz', 'mode': 't',
! \ 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
! \ 'lnum': lnum + 1, 'rhs': 'foo',
\ 'buffer': 0},
\ maparg('baz', 't', 0, 1))
*** ../vim-8.2.4139/src/version.c 2022-01-18 20:30:31.408458462 +0000
--- src/version.c 2022-01-18 20:50:02.966651252 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4140,
/**/
--
ARTHUR: A scratch? Your arm's off!
BLACK KNIGHT: No, it isn't.
ARTHUR: Well, what's that then?
BLACK KNIGHT: I've had worse.
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220118205206.4E05D1C044E%40moolenaar.net.