forked from aniani/vim
patch 8.2.4140: maparg() does not indicate the type of script
Problem: maparg() does not indicate the type of script where it was defined. Solution: Add "scriptversion".
This commit is contained in:
16
src/map.c
16
src/map.c
@@ -222,6 +222,7 @@ map_add(
|
||||
#ifdef FEAT_EVAL
|
||||
int expr,
|
||||
scid_T sid, // -1 to use current_sctx
|
||||
int scriptversion,
|
||||
linenr_T lnum,
|
||||
#endif
|
||||
int simplified)
|
||||
@@ -259,11 +260,11 @@ map_add(
|
||||
mp->m_simplified = simplified;
|
||||
#ifdef FEAT_EVAL
|
||||
mp->m_expr = expr;
|
||||
if (sid >= 0)
|
||||
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;
|
||||
mp->m_script_ctx.sc_version = scriptversion;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -844,7 +845,7 @@ do_map(
|
||||
if (map_add(map_table, abbr_table, keys, rhs, orig_rhs,
|
||||
noremap, nowait, silent, mode, abbrev,
|
||||
#ifdef FEAT_EVAL
|
||||
expr, /* sid */ -1, /* lnum */ 0,
|
||||
expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0,
|
||||
#endif
|
||||
did_simplify && keyround == 1) == FAIL)
|
||||
{
|
||||
@@ -2302,6 +2303,8 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
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,6 +2374,7 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
int silent;
|
||||
int buffer;
|
||||
scid_T sid;
|
||||
int scriptversion;
|
||||
linenr_T lnum;
|
||||
mapblock_T **map_table = maphash;
|
||||
mapblock_T **abbr_table = &first_abbr;
|
||||
@@ -2416,6 +2420,7 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
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,10 +2451,11 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
vim_free(arg);
|
||||
|
||||
(void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap,
|
||||
nowait, silent, mode, is_abbr, expr, sid, lnum, 0);
|
||||
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, lnum, 1);
|
||||
nowait, silent, mode, is_abbr, expr, sid, scriptversion,
|
||||
lnum, 1);
|
||||
vim_free(keys_buf);
|
||||
vim_free(arg_buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user