]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4357: sticky command modifiers are too sticky v8.2.4357
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Feb 2022 13:30:17 +0000 (13:30 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Feb 2022 13:30:17 +0000 (13:30 +0000)
Problem:    sticky command modifiers are too sticky.
Solution:   Do not apply command modifiers to a sourced script. (closes #9751)

src/scriptfile.c
src/testdir/test_vim9_cmd.vim
src/version.c

index 3b9fec1cd51ebeaf510b24760b1d4f9777e99c71..2606737545750cc8c5a817d8465f2f53f837d92c 100644 (file)
@@ -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
index 4398cbf4f64a1d21c0ecc4b3f70e997996394dc7..a9309bea7f162423befa275fc89bac14daf50c23 100644 (file)
@@ -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()
index 590aeb712c55d1e3cdf4e813da3f530be2fcbd55..7e5d18fae4797a950294183648e1b03520e89d6c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4357,
 /**/
     4356,
 /**/