]> granicus.if.org Git - vim/commitdiff
patch 8.2.2215: Vim9: not recognized in global command v8.2.2215
authorBram Moolenaar <Bram@vim.org>
Fri, 25 Dec 2020 17:35:29 +0000 (18:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 25 Dec 2020 17:35:29 +0000 (18:35 +0100)
Problem:    Vim9:  not recognized in global command.
Solution:   Skip over pattern. (issue #7541)

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

index f05872ef23d55a78467815fc1d80f2860b5ad144..9790789a07576b73ffc4beba90d5e8b5c6353788 100644 (file)
@@ -25,6 +25,15 @@ def Test_edit_wildcards()
   CheckDefFailure(['edit `="foo"'], 'E1083:')
 enddef
 
+def Test_global_backtick_expansion()
+  new
+  setline(1, 'xx')
+  var name = 'foobar'
+  g/^xx/s/.*/`=name`
+  assert_equal('foobar', getline(1))
+  bwipe!
+enddef
+
 def Test_hardcopy_wildcards()
   CheckUnix
   CheckFeature postscript
index ff9652356e77dba25c6e7b3a42c6e36ef689247b..8f9a54e0ea70c57a0cfe4072ed02fb79b4cbbffa 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2215,
 /**/
     2214,
 /**/
index 53a61051cbc77bd432b34e379a06c384a9c1b845..b035333d27da777dc9c7c0d4afec35913c90be35 100644 (file)
@@ -2947,7 +2947,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
 }
 
 /*
- * parse a lambda: {arg, arg -> expr}
+ * parse a lambda: "{arg, arg -> expr}" or "(arg, arg) => expr"
  * "*arg" points to the '{'.
  */
     static int
@@ -7315,6 +7315,19 @@ compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
            eap->arg = skiptowhite(eap->arg);
     }
 
+    if ((eap->cmdidx == CMD_global || eap->cmdidx == CMD_vglobal)
+                                                      && STRLEN(eap->arg) > 4)
+    {
+       int delim = *eap->arg;
+
+       p = skip_regexp_ex(eap->arg + 1, delim, TRUE, NULL, NULL);
+       if (*p == delim)
+       {
+           eap->arg = p + 1;
+           has_expr = TRUE;
+       }
+    }
+
     if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
     {
        int     count = 0;