Mirror of the Vim source from https://github.com/vim/vim
Révision | 67194006cad88030761f1258a46f7287fdcc3f44 (tree) |
---|---|
l'heure | 2022-01-16 22:45:03 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 8.2.4107: script context not restored after using <ScriptCmd>
Commit: https://github.com/vim/vim/commit/a9725221ac4650b7e9219bf6e3682826fe2e0096
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 16 13:30:33 2022 +0000
@@ -2394,6 +2394,9 @@ | ||
2394 | 2394 | Note that if you manage to call feedkeys() while |
2395 | 2395 | executing commands, thus calling it recursively, then |
2396 | 2396 | all typeahead will be consumed by the last call. |
2397 | + 'c' Remove any script context when executing, so that | |
2398 | + legacy script syntax applies, "s:var" does not work, | |
2399 | + etc. | |
2397 | 2400 | '!' When used with 'x' will not end Insert mode. Can be |
2398 | 2401 | used in a test when a timer is set to exit Insert mode |
2399 | 2402 | a little later. Useful for testing CursorHoldI. |
@@ -3932,6 +3932,7 @@ | ||
3932 | 3932 | char_u nbuf[NUMBUFLEN]; |
3933 | 3933 | int typed = FALSE; |
3934 | 3934 | int execute = FALSE; |
3935 | + int context = FALSE; | |
3935 | 3936 | int dangerous = FALSE; |
3936 | 3937 | int lowlevel = FALSE; |
3937 | 3938 | char_u *keys_esc; |
@@ -3961,6 +3962,7 @@ | ||
3961 | 3962 | case 't': typed = TRUE; break; |
3962 | 3963 | case 'i': insert = TRUE; break; |
3963 | 3964 | case 'x': execute = TRUE; break; |
3965 | + case 'c': context = TRUE; break; | |
3964 | 3966 | case '!': dangerous = TRUE; break; |
3965 | 3967 | case 'L': lowlevel = TRUE; break; |
3966 | 3968 | } |
@@ -4007,11 +4009,19 @@ | ||
4007 | 4009 | |
4008 | 4010 | if (execute) |
4009 | 4011 | { |
4010 | - int save_msg_scroll = msg_scroll; | |
4012 | + int save_msg_scroll = msg_scroll; | |
4013 | + sctx_T save_sctx; | |
4011 | 4014 | |
4012 | 4015 | // Avoid a 1 second delay when the keys start Insert mode. |
4013 | 4016 | msg_scroll = FALSE; |
4014 | 4017 | |
4018 | + if (context) | |
4019 | + { | |
4020 | + save_sctx = current_sctx; | |
4021 | + current_sctx.sc_sid = 0; | |
4022 | + current_sctx.sc_version = 0; | |
4023 | + } | |
4024 | + | |
4015 | 4025 | if (!dangerous) |
4016 | 4026 | { |
4017 | 4027 | ++ex_normal_busy; |
@@ -4025,6 +4035,9 @@ | ||
4025 | 4035 | } |
4026 | 4036 | |
4027 | 4037 | msg_scroll |= save_msg_scroll; |
4038 | + | |
4039 | + if (context) | |
4040 | + current_sctx = save_sctx; | |
4028 | 4041 | } |
4029 | 4042 | } |
4030 | 4043 | } |
@@ -3797,7 +3797,7 @@ | ||
3797 | 3797 | } |
3798 | 3798 | } |
3799 | 3799 | else |
3800 | - ga_append(&line_ga, (char)c1); | |
3800 | + ga_append(&line_ga, c1); | |
3801 | 3801 | |
3802 | 3802 | cmod = 0; |
3803 | 3803 | } |
@@ -3815,7 +3815,7 @@ | ||
3815 | 3815 | { |
3816 | 3816 | int res; |
3817 | 3817 | #ifdef FEAT_EVAL |
3818 | - sctx_T save_current_sctx = {0, 0, 0, 0}; | |
3818 | + sctx_T save_current_sctx = {-1, 0, 0, 0}; | |
3819 | 3819 | |
3820 | 3820 | if (key == K_SCRIPT_COMMAND && last_used_map != NULL) |
3821 | 3821 | { |
@@ -3827,7 +3827,7 @@ | ||
3827 | 3827 | res = do_cmdline(NULL, getcmdkeycmd, NULL, flags); |
3828 | 3828 | |
3829 | 3829 | #ifdef FEAT_EVAL |
3830 | - if (save_current_sctx.sc_sid > 0) | |
3830 | + if (save_current_sctx.sc_sid >= 0) | |
3831 | 3831 | current_sctx = save_current_sctx; |
3832 | 3832 | #endif |
3833 | 3833 |
@@ -4,6 +4,7 @@ | ||
4 | 4 | source check.vim |
5 | 5 | source screendump.vim |
6 | 6 | source term_util.vim |
7 | +source vim9.vim | |
7 | 8 | |
8 | 9 | func Test_abbreviation() |
9 | 10 | " abbreviation with 0x80 should work |
@@ -1397,6 +1398,19 @@ | ||
1397 | 1398 | ounmap i- |
1398 | 1399 | endfunc |
1399 | 1400 | |
1401 | +func Test_map_script_cmd_restore() | |
1402 | + let lines =<< trim END | |
1403 | + vim9script | |
1404 | + nnoremap <F3> <ScriptCmd>eval 1 + 2<CR> | |
1405 | + END | |
1406 | + call CheckScriptSuccess(lines) | |
1407 | + call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc') | |
1408 | + call assert_equal(7, g:result) | |
1409 | + | |
1410 | + nunmap <F3> | |
1411 | + unlet g:result | |
1412 | +endfunc | |
1413 | + | |
1400 | 1414 | " Test for using <script> with a map to remap characters in rhs |
1401 | 1415 | func Test_script_local_remap() |
1402 | 1416 | new |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 4107, | |
755 | +/**/ | |
754 | 756 | 4106, |
755 | 757 | /**/ |
756 | 758 | 4105, |