Mercurial > vim
comparison src/map.c @ 27223:ea2b4cb4515b v8.2.4140
patch 8.2.4140: maparg() does not indicate the type of script
Commit: https://github.com/vim/vim/commit/a9528b39a666dbaa026320f73bae4b1628a7fe51
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 18 20:51:35 2022 +0000
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".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 18 Jan 2022 22:00:05 +0100 |
parents | 165a799b4129 |
children | bd072d44eb2c |
comparison
equal
deleted
inserted
replaced
27222:20f098f8b3e6 | 27223:ea2b4cb4515b |
---|---|
220 int mode, | 220 int mode, |
221 int is_abbr, | 221 int is_abbr, |
222 #ifdef FEAT_EVAL | 222 #ifdef FEAT_EVAL |
223 int expr, | 223 int expr, |
224 scid_T sid, // -1 to use current_sctx | 224 scid_T sid, // -1 to use current_sctx |
225 int scriptversion, | |
225 linenr_T lnum, | 226 linenr_T lnum, |
226 #endif | 227 #endif |
227 int simplified) | 228 int simplified) |
228 { | 229 { |
229 mapblock_T *mp = ALLOC_CLEAR_ONE(mapblock_T); | 230 mapblock_T *mp = ALLOC_CLEAR_ONE(mapblock_T); |
257 mp->m_silent = silent; | 258 mp->m_silent = silent; |
258 mp->m_mode = mode; | 259 mp->m_mode = mode; |
259 mp->m_simplified = simplified; | 260 mp->m_simplified = simplified; |
260 #ifdef FEAT_EVAL | 261 #ifdef FEAT_EVAL |
261 mp->m_expr = expr; | 262 mp->m_expr = expr; |
262 if (sid >= 0) | 263 if (sid > 0) |
263 { | 264 { |
264 mp->m_script_ctx.sc_sid = sid; | 265 mp->m_script_ctx.sc_sid = sid; |
265 mp->m_script_ctx.sc_lnum = lnum; | 266 mp->m_script_ctx.sc_lnum = lnum; |
266 mp->m_script_ctx.sc_version = in_vim9script() ? SCRIPT_VERSION_VIM9 : 0; | 267 mp->m_script_ctx.sc_version = scriptversion; |
267 } | 268 } |
268 else | 269 else |
269 { | 270 { |
270 mp->m_script_ctx = current_sctx; | 271 mp->m_script_ctx = current_sctx; |
271 mp->m_script_ctx.sc_lnum += SOURCING_LNUM; | 272 mp->m_script_ctx.sc_lnum += SOURCING_LNUM; |
842 | 843 |
843 // Get here when adding a new entry to the maphash[] list or abbrlist. | 844 // Get here when adding a new entry to the maphash[] list or abbrlist. |
844 if (map_add(map_table, abbr_table, keys, rhs, orig_rhs, | 845 if (map_add(map_table, abbr_table, keys, rhs, orig_rhs, |
845 noremap, nowait, silent, mode, abbrev, | 846 noremap, nowait, silent, mode, abbrev, |
846 #ifdef FEAT_EVAL | 847 #ifdef FEAT_EVAL |
847 expr, /* sid */ -1, /* lnum */ 0, | 848 expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0, |
848 #endif | 849 #endif |
849 did_simplify && keyround == 1) == FAIL) | 850 did_simplify && keyround == 1) == FAIL) |
850 { | 851 { |
851 retval = 4; // no mem | 852 retval = 4; // no mem |
852 goto theend; | 853 goto theend; |
2300 dict_add_number(dict, "script", mp->m_noremap == REMAP_SCRIPT | 2301 dict_add_number(dict, "script", mp->m_noremap == REMAP_SCRIPT |
2301 ? 1L : 0L); | 2302 ? 1L : 0L); |
2302 dict_add_number(dict, "expr", mp->m_expr ? 1L : 0L); | 2303 dict_add_number(dict, "expr", mp->m_expr ? 1L : 0L); |
2303 dict_add_number(dict, "silent", mp->m_silent ? 1L : 0L); | 2304 dict_add_number(dict, "silent", mp->m_silent ? 1L : 0L); |
2304 dict_add_number(dict, "sid", (long)mp->m_script_ctx.sc_sid); | 2305 dict_add_number(dict, "sid", (long)mp->m_script_ctx.sc_sid); |
2306 dict_add_number(dict, "scriptversion", | |
2307 (long)mp->m_script_ctx.sc_version); | |
2305 dict_add_number(dict, "lnum", (long)mp->m_script_ctx.sc_lnum); | 2308 dict_add_number(dict, "lnum", (long)mp->m_script_ctx.sc_lnum); |
2306 dict_add_number(dict, "buffer", (long)buffer_local); | 2309 dict_add_number(dict, "buffer", (long)buffer_local); |
2307 dict_add_number(dict, "nowait", mp->m_nowait ? 1L : 0L); | 2310 dict_add_number(dict, "nowait", mp->m_nowait ? 1L : 0L); |
2308 dict_add_string(dict, "mode", mapmode); | 2311 dict_add_string(dict, "mode", mapmode); |
2309 | 2312 |
2369 int noremap; | 2372 int noremap; |
2370 int expr; | 2373 int expr; |
2371 int silent; | 2374 int silent; |
2372 int buffer; | 2375 int buffer; |
2373 scid_T sid; | 2376 scid_T sid; |
2377 int scriptversion; | |
2374 linenr_T lnum; | 2378 linenr_T lnum; |
2375 mapblock_T **map_table = maphash; | 2379 mapblock_T **map_table = maphash; |
2376 mapblock_T **abbr_table = &first_abbr; | 2380 mapblock_T **abbr_table = &first_abbr; |
2377 int nowait; | 2381 int nowait; |
2378 char_u *arg; | 2382 char_u *arg; |
2414 if (dict_get_number(d, (char_u *)"script") != 0) | 2418 if (dict_get_number(d, (char_u *)"script") != 0) |
2415 noremap = REMAP_SCRIPT; | 2419 noremap = REMAP_SCRIPT; |
2416 expr = dict_get_number(d, (char_u *)"expr") != 0; | 2420 expr = dict_get_number(d, (char_u *)"expr") != 0; |
2417 silent = dict_get_number(d, (char_u *)"silent") != 0; | 2421 silent = dict_get_number(d, (char_u *)"silent") != 0; |
2418 sid = dict_get_number(d, (char_u *)"sid"); | 2422 sid = dict_get_number(d, (char_u *)"sid"); |
2423 scriptversion = dict_get_number(d, (char_u *)"scriptversion"); | |
2419 lnum = dict_get_number(d, (char_u *)"lnum"); | 2424 lnum = dict_get_number(d, (char_u *)"lnum"); |
2420 buffer = dict_get_number(d, (char_u *)"buffer"); | 2425 buffer = dict_get_number(d, (char_u *)"buffer"); |
2421 nowait = dict_get_number(d, (char_u *)"nowait") != 0; | 2426 nowait = dict_get_number(d, (char_u *)"nowait") != 0; |
2422 // mode from the dict is not used | 2427 // mode from the dict is not used |
2423 | 2428 |
2444 } | 2449 } |
2445 do_map(1, arg, mode, is_abbr); | 2450 do_map(1, arg, mode, is_abbr); |
2446 vim_free(arg); | 2451 vim_free(arg); |
2447 | 2452 |
2448 (void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap, | 2453 (void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap, |
2449 nowait, silent, mode, is_abbr, expr, sid, lnum, 0); | 2454 nowait, silent, mode, is_abbr, expr, sid, scriptversion, lnum, 0); |
2450 if (lhsrawalt != NULL) | 2455 if (lhsrawalt != NULL) |
2451 (void)map_add(map_table, abbr_table, lhsrawalt, rhs, orig_rhs, noremap, | 2456 (void)map_add(map_table, abbr_table, lhsrawalt, rhs, orig_rhs, noremap, |
2452 nowait, silent, mode, is_abbr, expr, sid, lnum, 1); | 2457 nowait, silent, mode, is_abbr, expr, sid, scriptversion, |
2458 lnum, 1); | |
2453 vim_free(keys_buf); | 2459 vim_free(keys_buf); |
2454 vim_free(arg_buf); | 2460 vim_free(arg_buf); |
2455 } | 2461 } |
2456 #endif | 2462 #endif |
2457 | 2463 |