0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4357: sticky command modifiers are too sticky

Problem:    sticky command modifiers are too sticky.
Solution:   Do not apply command modifiers to a sourced script. (closes #9751)
This commit is contained in:
Bram Moolenaar
2022-02-12 13:30:17 +00:00
parent 620d8edba0
commit 2a9b62dfa2
3 changed files with 19 additions and 0 deletions

View File

@@ -1254,6 +1254,7 @@ do_source(
#ifdef FEAT_PROFILE #ifdef FEAT_PROFILE
proftime_T wait_start; proftime_T wait_start;
#endif #endif
int save_sticky_cmdmod_flags = sticky_cmdmod_flags;
int trigger_source_post = FALSE; int trigger_source_post = FALSE;
ESTACK_CHECK_DECLARATION ESTACK_CHECK_DECLARATION
@@ -1394,6 +1395,9 @@ do_source(
time_push(&tv_rel, &tv_start); time_push(&tv_rel, &tv_start);
#endif #endif
// "legacy" does not apply to commands in the script
sticky_cmdmod_flags = 0;
save_current_sctx = current_sctx; save_current_sctx = current_sctx;
current_sctx.sc_version = 1; // default script version current_sctx.sc_version = 1; // default script version
@@ -1618,6 +1622,7 @@ almosttheend:
theend: theend:
vim_free(fname_exp); vim_free(fname_exp);
sticky_cmdmod_flags = save_sticky_cmdmod_flags;
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
estack_compiling = save_estack_compiling; estack_compiling = save_estack_compiling;
#endif #endif

View File

@@ -106,6 +106,18 @@ def Test_cmdmod_execute()
unlet b:undo unlet b:undo
unlet g:undone unlet g:undone
unlet g:undtwo unlet g:undtwo
# "legacy" does not apply to a loaded script
lines =<< trim END
vim9script
export var exported = 'x'
END
writefile(lines, 'Xvim9import.vim')
lines =<< trim END
legacy exe "import './Xvim9import.vim'"
END
v9.CheckScriptSuccess(lines)
delete('Xvim9import.vim')
enddef enddef
def Test_edit_wildcards() def Test_edit_wildcards()

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4357,
/**/ /**/
4356, 4356,
/**/ /**/