• R/O
  • SSH

vim: コミット

Mirror of the Vim source from https://github.com/vim/vim


コミットメタ情報

リビジョンea2b4cb4515bea34b68cc6062ddecdaae3453499 (tree)
日時2022-01-19 06:00:05
作者Bram Moolenaar <Bram@vim....>
コミッターBram Moolenaar

ログメッセージ

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".

変更サマリ

差分

diff -r 20f098f8b3e6 -r ea2b4cb4515b runtime/doc/builtin.txt
--- a/runtime/doc/builtin.txt Tue Jan 18 21:45:03 2022 +0100
+++ b/runtime/doc/builtin.txt Tue Jan 18 22:00:05 2022 +0100
@@ -5247,6 +5247,8 @@
52475247 (|mapmode-ic|)
52485248 "sid" The script local ID, used for <sid> mappings
52495249 (|<SID>|).
5250+ "scriptversion" The version of the script. 999999 for
5251+ |Vim9| script.
52505252 "lnum" The line number in "sid", zero if unknown.
52515253 "nowait" Do not wait for other, longer mappings.
52525254 (|:map-<nowait>|).
diff -r 20f098f8b3e6 -r ea2b4cb4515b src/map.c
--- a/src/map.c Tue Jan 18 21:45:03 2022 +0100
+++ b/src/map.c Tue Jan 18 22:00:05 2022 +0100
@@ -222,6 +222,7 @@
222222 #ifdef FEAT_EVAL
223223 int expr,
224224 scid_T sid, // -1 to use current_sctx
225+ int scriptversion,
225226 linenr_T lnum,
226227 #endif
227228 int simplified)
@@ -259,11 +260,11 @@
259260 mp->m_simplified = simplified;
260261 #ifdef FEAT_EVAL
261262 mp->m_expr = expr;
262- if (sid >= 0)
263+ if (sid > 0)
263264 {
264265 mp->m_script_ctx.sc_sid = sid;
265266 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;
267268 }
268269 else
269270 {
@@ -844,7 +845,7 @@
844845 if (map_add(map_table, abbr_table, keys, rhs, orig_rhs,
845846 noremap, nowait, silent, mode, abbrev,
846847 #ifdef FEAT_EVAL
847- expr, /* sid */ -1, /* lnum */ 0,
848+ expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0,
848849 #endif
849850 did_simplify && keyround == 1) == FAIL)
850851 {
@@ -2302,6 +2303,8 @@
23022303 dict_add_number(dict, "expr", mp->m_expr ? 1L : 0L);
23032304 dict_add_number(dict, "silent", mp->m_silent ? 1L : 0L);
23042305 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);
23052308 dict_add_number(dict, "lnum", (long)mp->m_script_ctx.sc_lnum);
23062309 dict_add_number(dict, "buffer", (long)buffer_local);
23072310 dict_add_number(dict, "nowait", mp->m_nowait ? 1L : 0L);
@@ -2371,6 +2374,7 @@
23712374 int silent;
23722375 int buffer;
23732376 scid_T sid;
2377+ int scriptversion;
23742378 linenr_T lnum;
23752379 mapblock_T **map_table = maphash;
23762380 mapblock_T **abbr_table = &first_abbr;
@@ -2416,6 +2420,7 @@
24162420 expr = dict_get_number(d, (char_u *)"expr") != 0;
24172421 silent = dict_get_number(d, (char_u *)"silent") != 0;
24182422 sid = dict_get_number(d, (char_u *)"sid");
2423+ scriptversion = dict_get_number(d, (char_u *)"scriptversion");
24192424 lnum = dict_get_number(d, (char_u *)"lnum");
24202425 buffer = dict_get_number(d, (char_u *)"buffer");
24212426 nowait = dict_get_number(d, (char_u *)"nowait") != 0;
@@ -2446,10 +2451,11 @@
24462451 vim_free(arg);
24472452
24482453 (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);
24502455 if (lhsrawalt != NULL)
24512456 (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);
24532459 vim_free(keys_buf);
24542460 vim_free(arg_buf);
24552461 }
diff -r 20f098f8b3e6 -r ea2b4cb4515b src/testdir/test_maparg.vim
--- a/src/testdir/test_maparg.vim Tue Jan 18 21:45:03 2022 +0100
+++ b/src/testdir/test_maparg.vim Tue Jan 18 22:00:05 2022 +0100
@@ -18,26 +18,30 @@
1818 call assert_equal("is<F4>foo", maparg('foo<C-V>'))
1919 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
2020 \ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16",
21- \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
21+ \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
22+ \ 'lnum': lnum + 1,
2223 \ 'rhs': 'is<F4>foo', 'buffer': 0},
2324 \ maparg('foo<C-V>', '', 0, 1))
2425 call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar',
2526 \ 'lhsraw': 'bar', 'mode': 'v',
26- \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
27+ \ 'nowait': 0, 'expr': 1, 'sid': sid, 'scriptversion': 1,
28+ \ 'lnum': lnum + 2,
2729 \ 'rhs': 'isbar', 'buffer': 1},
2830 \ 'bar'->maparg('', 0, 1))
2931 let lnum = expand('<sflnum>')
3032 map <buffer> <nowait> foo bar
3133 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo',
3234 \ 'lhsraw': 'foo', 'mode': ' ',
33- \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
35+ \ 'nowait': 1, 'expr': 0, 'sid': sid, 'scriptversion': 1,
36+ \ 'lnum': lnum + 1, 'rhs': 'bar',
3437 \ 'buffer': 1},
3538 \ maparg('foo', '', 0, 1))
3639 let lnum = expand('<sflnum>')
3740 tmap baz foo
3841 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz',
3942 \ 'lhsraw': 'baz', 'mode': 't',
40- \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
43+ \ 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
44+ \ 'lnum': lnum + 1, 'rhs': 'foo',
4145 \ 'buffer': 0},
4246 \ maparg('baz', 't', 0, 1))
4347
diff -r 20f098f8b3e6 -r ea2b4cb4515b src/version.c
--- a/src/version.c Tue Jan 18 21:45:03 2022 +0100
+++ b/src/version.c Tue Jan 18 22:00:05 2022 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 4140,
755+/**/
754756 4139,
755757 /**/
756758 4138,
旧リポジトリブラウザで表示