summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-25 18:35:29 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-25 18:35:29 +0100
commit56ce9ea3ea46529cac2fdf3151abfa0e1ae49bad (patch)
treeac0550cf30c9dc2b19febb43f03762b5bd67c739
parentf8103f274e828bdc2dcbc4d857f166f25e0a855e (diff)
downloadvim-git-56ce9ea3ea46529cac2fdf3151abfa0e1ae49bad.tar.gz
patch 8.2.2215: Vim9: not recognized in global commandv8.2.2215
Problem: Vim9: not recognized in global command. Solution: Skip over pattern. (issue #7541)
-rw-r--r--src/testdir/test_vim9_cmd.vim9
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c15
3 files changed, 25 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index f05872ef2..9790789a0 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index ff9652356..8f9a54e0e 100644
--- 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 */
/**/
+ 2215,
+/**/
2214,
/**/
2213,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 53a61051c..b035333d2 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -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;