Patch 8.2.4107
Problem: Script context not restored after using <ScriptCmd>.
Solution: Also restore context when not in a script. (closes #9536)
Add the 'c' flag to feedkeys() to be able to test this.
Files: runtime/doc/builtin.txt, src/getchar.c, src/evalfunc.c,
src/testdir/test_mapping.vim
*** ../vim-8.2.4106/runtime/doc/builtin.txt 2022-01-10 13:36:31.260892426
+0000
--- runtime/doc/builtin.txt 2022-01-16 13:22:02.786692066 +0000
***************
*** 2394,2399 ****
--- 2394,2402 ----
Note that if you manage to call feedkeys() while
executing commands, thus calling it recursively, then
all typeahead will be consumed by the last call.
+ 'c' Remove any script context when executing, so that
+ legacy script syntax applies, "s:var" does not work,
+ etc.
'!' When used with 'x' will not end Insert mode. Can be
used in a test when a timer is set to exit Insert mode
a little later. Useful for testing CursorHoldI.
*** ../vim-8.2.4106/src/getchar.c 2022-01-15 18:48:28.602361973 +0000
--- src/getchar.c 2022-01-16 13:29:19.257823117 +0000
***************
*** 3797,3803 ****
}
}
else
! ga_append(&line_ga, (char)c1);
cmod = 0;
}
--- 3797,3803 ----
}
}
else
! ga_append(&line_ga, c1);
cmod = 0;
}
***************
*** 3815,3821 ****
{
int res;
#ifdef FEAT_EVAL
! sctx_T save_current_sctx = {0, 0, 0, 0};
if (key == K_SCRIPT_COMMAND && last_used_map != NULL)
{
--- 3815,3821 ----
{
int res;
#ifdef FEAT_EVAL
! sctx_T save_current_sctx = {-1, 0, 0, 0};
if (key == K_SCRIPT_COMMAND && last_used_map != NULL)
{
***************
*** 3827,3833 ****
res = do_cmdline(NULL, getcmdkeycmd, NULL, flags);
#ifdef FEAT_EVAL
! if (save_current_sctx.sc_sid > 0)
current_sctx = save_current_sctx;
#endif
--- 3827,3833 ----
res = do_cmdline(NULL, getcmdkeycmd, NULL, flags);
#ifdef FEAT_EVAL
! if (save_current_sctx.sc_sid >= 0)
current_sctx = save_current_sctx;
#endif
*** ../vim-8.2.4106/src/evalfunc.c 2022-01-13 21:15:17.237958552 +0000
--- src/evalfunc.c 2022-01-16 13:24:22.010406837 +0000
***************
*** 3932,3937 ****
--- 3932,3938 ----
char_u nbuf[NUMBUFLEN];
int typed = FALSE;
int execute = FALSE;
+ int context = FALSE;
int dangerous = FALSE;
int lowlevel = FALSE;
char_u *keys_esc;
***************
*** 3961,3966 ****
--- 3962,3968 ----
case 't': typed = TRUE; break;
case 'i': insert = TRUE; break;
case 'x': execute = TRUE; break;
+ case 'c': context = TRUE; break;
case '!': dangerous = TRUE; break;
case 'L': lowlevel = TRUE; break;
}
***************
*** 4007,4017 ****
if (execute)
{
! int save_msg_scroll = msg_scroll;
// Avoid a 1 second delay when the keys start Insert mode.
msg_scroll = FALSE;
if (!dangerous)
{
++ex_normal_busy;
--- 4009,4027 ----
if (execute)
{
! int save_msg_scroll = msg_scroll;
! sctx_T save_sctx;
// Avoid a 1 second delay when the keys start Insert mode.
msg_scroll = FALSE;
+ if (context)
+ {
+ save_sctx = current_sctx;
+ current_sctx.sc_sid = 0;
+ current_sctx.sc_version = 0;
+ }
+
if (!dangerous)
{
++ex_normal_busy;
***************
*** 4025,4030 ****
--- 4035,4043 ----
}
msg_scroll |= save_msg_scroll;
+
+ if (context)
+ current_sctx = save_sctx;
}
}
}
*** ../vim-8.2.4106/src/testdir/test_mapping.vim 2022-01-13
15:25:28.222535371 +0000
--- src/testdir/test_mapping.vim 2022-01-16 13:28:26.785924258 +0000
***************
*** 4,9 ****
--- 4,10 ----
source check.vim
source screendump.vim
source term_util.vim
+ source vim9.vim
func Test_abbreviation()
" abbreviation with 0x80 should work
***************
*** 1397,1402 ****
--- 1398,1416 ----
ounmap i-
endfunc
+ func Test_map_script_cmd_restore()
+ let lines =<< trim END
+ vim9script
+ nnoremap <F3> <ScriptCmd>eval 1 + 2<CR>
+ END
+ call CheckScriptSuccess(lines)
+ call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc')
+ call assert_equal(7, g:result)
+
+ nunmap <F3>
+ unlet g:result
+ endfunc
+
" Test for using <script> with a map to remap characters in rhs
func Test_script_local_remap()
new
*** ../vim-8.2.4106/src/version.c 2022-01-16 11:42:16.180527699 +0000
--- src/version.c 2022-01-16 12:32:42.549356905 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4107,
/**/
--
ARTHUR: Will you ask your master if he wants to join my court at Camelot?!
GUARD #1: But then of course African swallows are not migratory.
GUARD #2: Oh, yeah...
GUARD #1: So they couldn't bring a coconut back anyway...
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/20220116133223.5418B1C05EF%40moolenaar.net.