]> granicus.if.org Git - vim/commitdiff
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script v8.2.0306
authorBram Moolenaar <Bram@vim.org>
Sun, 23 Feb 2020 13:35:01 +0000 (14:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Feb 2020 13:35:01 +0000 (14:35 +0100)
Problem:    Vim9: :substitute(pat(repl does not work in Vim9 script.
Solution:   Remember starting with a colon. (closes #5676)

src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c

index 70c0da2f033ac6d493a242c55cf0f57f82608fd6..62cab6e22f85812eb2c2189f9144324ccfc0fb2d 100644 (file)
@@ -1647,6 +1647,9 @@ do_one_cmd(
     int                save_reg_executing = reg_executing;
     int                ni;                     // set when Not Implemented
     char_u     *cmd;
+#ifdef FEAT_EVAL
+    int                starts_with_colon;
+#endif
 
     vim_memset(&ea, 0, sizeof(ea));
     ea.line1 = 1;
@@ -1689,6 +1692,7 @@ do_one_cmd(
     ea.cookie = cookie;
 #ifdef FEAT_EVAL
     ea.cstack = cstack;
+    starts_with_colon = *skipwhite(ea.cmd) == ':';
 #endif
     if (parse_command_modifiers(&ea, &errormsg, FALSE) == FAIL)
        goto doend;
@@ -1713,7 +1717,7 @@ do_one_cmd(
        ea.cmd = skipwhite(ea.cmd + 1);
 
 #ifdef FEAT_EVAL
-    if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+    if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon)
        p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
     else
 #endif
index 5dbc9f9ea7772d8ea016caf51828741368928b65..a7bccec4e241280946001c37acc6352e34f7e164 100644 (file)
@@ -580,6 +580,21 @@ def Test_substitute_cmd()
   setline(1, 'something')
   :substitute(some(other(
   assert_equal('otherthing', getline(1))
+  bwipe!
+
+  " also when the context is Vim9 script
+  let lines =<< trim END
+    vim9script
+    new
+    setline(1, 'something')
+    :substitute(some(other(
+    assert_equal('otherthing', getline(1))
+    bwipe!
+  END
+  writefile(lines, 'Xvim9lines')
+  source Xvim9lines
+
+  delete('Xvim9lines')
 enddef
 
 
index 2c4f78b42c9635393348059c7a1bfc9527b3bba9..49cdcc5da7d07a7b97fd3cf23174605361c4136b 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    306,
 /**/
     305,
 /**/