Mercurial > vim
diff src/evalfunc.c @ 27156:67194006cad8 v8.2.4107
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
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 https://github.com/vim/vim/issues/9536)
Add the 'c' flag to feedkeys() to be able to test this.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 16 Jan 2022 14:45:03 +0100 |
parents | 98a01021e465 |
children | e91b577be192 |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3932,6 +3932,7 @@ f_feedkeys(typval_T *argvars, typval_T * 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 * 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 * 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 * } msg_scroll |= save_msg_scroll; + + if (context) + current_sctx = save_sctx; } } }