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.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index f44207d..c731280 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3932,6 +3932,7 @@
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 @@
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 @@
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 @@
}
msg_scroll |= save_msg_scroll;
+
+ if (context)
+ current_sctx = save_sctx;
}
}
}