patch 8.2.3710: Vim9: backtick expression expanded for :global
Problem: Vim9: backtick expression expanded for :global.
Solution: Check the following command.
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 2fbccf4..ece3f73 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -183,11 +183,18 @@
enddef
def Test_global_backtick_expansion()
+ var name = 'xxx'
new
- setline(1, 'xx')
- var name = 'foobar'
- g/^xx/s/.*/`=name`
- assert_equal('foobar', getline(1))
+ setline(1, ['one', 'two', 'three'])
+ set nomod
+ g/two/edit `=name`
+ assert_equal('xxx', bufname())
+ bwipe!
+
+ new
+ setline(1, ['one', 'two', 'three'])
+ g/two/s/^/`=name`/
+ assert_equal('`=name`two', getline(2))
bwipe!
enddef
diff --git a/src/version.c b/src/version.c
index be24950..37d3832 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3710,
+/**/
3709,
/**/
3708,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 40dd00f..3f72c7f 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -9070,6 +9070,7 @@
int has_expr = FALSE;
char_u *nextcmd = (char_u *)"";
char_u *tofree = NULL;
+ char_u *cmd_arg = NULL;
if (cctx->ctx_skip == SKIP_YES)
goto theend;
@@ -9172,20 +9173,20 @@
p = skip_regexp_ex(eap->arg + 1, delim, TRUE, NULL, NULL, NULL);
if (*p == delim)
- {
- eap->arg = p + 1;
- has_expr = TRUE;
- }
+ cmd_arg = p + 1;
}
if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
+ cmd_arg = eap->arg;
+
+ if (cmd_arg != NULL)
{
exarg_T nea;
CLEAR_FIELD(nea);
- nea.cmd = eap->arg;
+ nea.cmd = cmd_arg;
p = find_ex_command(&nea, NULL, lookup_scriptitem, NULL);
- if (nea.cmdidx <= CMD_SIZE)
+ if (nea.cmdidx < CMD_SIZE)
{
has_expr = excmd_get_argt(nea.cmdidx) & (EX_XFILE | EX_EXPAND);
if (has_expr)