changeset 27663:df84fac1e9a4 v8.2.4357

patch 8.2.4357: sticky command modifiers are too sticky Commit: https://github.com/vim/vim/commit/2a9b62dfa2fb91a6ede9cb4d146ca47a1db31254 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 12 13:30:17 2022 +0000 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 https://github.com/vim/vim/issues/9751)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Feb 2022 14:45:05 +0100
parents 21654b0c1a95
children 7ea1e3b0b5ca
files src/scriptfile.c src/testdir/test_vim9_cmd.vim src/version.c
diffstat 3 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1254,6 +1254,7 @@ do_source(
 #ifdef FEAT_PROFILE
     proftime_T		    wait_start;
 #endif
+    int			    save_sticky_cmdmod_flags = sticky_cmdmod_flags;
     int			    trigger_source_post = FALSE;
     ESTACK_CHECK_DECLARATION
 
@@ -1394,6 +1395,9 @@ do_source(
 	time_push(&tv_rel, &tv_start);
 #endif
 
+    // "legacy" does not apply to commands in the script
+    sticky_cmdmod_flags = 0;
+
     save_current_sctx = current_sctx;
     current_sctx.sc_version = 1;  // default script version
 
@@ -1618,6 +1622,7 @@ almosttheend:
 
 theend:
     vim_free(fname_exp);
+    sticky_cmdmod_flags = save_sticky_cmdmod_flags;
 #ifdef FEAT_EVAL
     estack_compiling = save_estack_compiling;
 #endif
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -106,6 +106,18 @@ def Test_cmdmod_execute()
   unlet b:undo
   unlet g:undone
   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
 
 def Test_edit_wildcards()
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4357,
+/**/
     4356,
 /**/
     4355,