1
0
forked from aniani/vim

patch 8.2.4107: script context not restored after using <ScriptCmd>

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.
This commit is contained in:
Bram Moolenaar
2022-01-16 13:30:33 +00:00
parent fa1a457059
commit a9725221ac
5 changed files with 36 additions and 4 deletions

View File

@@ -3932,6 +3932,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
char_u nbuf[NUMBUFLEN];
int typed = FALSE;
int execute = FALSE;
int context = FALSE;
int dangerous = FALSE;
int lowlevel = FALSE;
char_u *keys_esc;
@@ -3961,6 +3962,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
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,11 +4009,19 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
if (execute)
{
int save_msg_scroll = msg_scroll;
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,6 +4035,9 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
}
msg_scroll |= save_msg_scroll;
if (context)
current_sctx = save_sctx;
}
}
}