comparison 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
comparison
equal deleted inserted replaced
27155:1ebb45dd9232 27156:67194006cad8
3930 int insert = FALSE; 3930 int insert = FALSE;
3931 char_u *keys, *flags; 3931 char_u *keys, *flags;
3932 char_u nbuf[NUMBUFLEN]; 3932 char_u nbuf[NUMBUFLEN];
3933 int typed = FALSE; 3933 int typed = FALSE;
3934 int execute = FALSE; 3934 int execute = FALSE;
3935 int context = FALSE;
3935 int dangerous = FALSE; 3936 int dangerous = FALSE;
3936 int lowlevel = FALSE; 3937 int lowlevel = FALSE;
3937 char_u *keys_esc; 3938 char_u *keys_esc;
3938 3939
3939 // This is not allowed in the sandbox. If the commands would still be 3940 // This is not allowed in the sandbox. If the commands would still be
3959 case 'n': remap = FALSE; break; 3960 case 'n': remap = FALSE; break;
3960 case 'm': remap = TRUE; break; 3961 case 'm': remap = TRUE; break;
3961 case 't': typed = TRUE; break; 3962 case 't': typed = TRUE; break;
3962 case 'i': insert = TRUE; break; 3963 case 'i': insert = TRUE; break;
3963 case 'x': execute = TRUE; break; 3964 case 'x': execute = TRUE; break;
3965 case 'c': context = TRUE; break;
3964 case '!': dangerous = TRUE; break; 3966 case '!': dangerous = TRUE; break;
3965 case 'L': lowlevel = TRUE; break; 3967 case 'L': lowlevel = TRUE; break;
3966 } 3968 }
3967 } 3969 }
3968 } 3970 }
4005 } 4007 }
4006 vim_free(keys_esc); 4008 vim_free(keys_esc);
4007 4009
4008 if (execute) 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 // Avoid a 1 second delay when the keys start Insert mode. 4015 // Avoid a 1 second delay when the keys start Insert mode.
4013 msg_scroll = FALSE; 4016 msg_scroll = FALSE;
4017
4018 if (context)
4019 {
4020 save_sctx = current_sctx;
4021 current_sctx.sc_sid = 0;
4022 current_sctx.sc_version = 0;
4023 }
4014 4024
4015 if (!dangerous) 4025 if (!dangerous)
4016 { 4026 {
4017 ++ex_normal_busy; 4027 ++ex_normal_busy;
4018 ++in_feedkeys; 4028 ++in_feedkeys;
4023 --ex_normal_busy; 4033 --ex_normal_busy;
4024 --in_feedkeys; 4034 --in_feedkeys;
4025 } 4035 }
4026 4036
4027 msg_scroll |= save_msg_scroll; 4037 msg_scroll |= save_msg_scroll;
4038
4039 if (context)
4040 current_sctx = save_sctx;
4028 } 4041 }
4029 } 4042 }
4030 } 4043 }
4031 } 4044 }
4032 4045