mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3710: Vim9: backtick expression expanded for :global
Problem: Vim9: backtick expression expanded for :global. Solution: Check the following command.
This commit is contained in:
@@ -1124,17 +1124,11 @@ function scope. Instead, use a lambda: >
|
|||||||
return range(1, 2)->map((_, v) => list[v])
|
return range(1, 2)->map((_, v) => list[v])
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
The same is true for commands that are not compiled, such as `:global`.
|
For commands that are not compiled, such as `:edit`, backtick expansion can be
|
||||||
For these the backtick expansion can be used. Example: >
|
used and it can use the local scope. Example: >
|
||||||
def Replace()
|
def Replace()
|
||||||
var newText = 'blah'
|
var fname = 'blah.txt'
|
||||||
g/pattern/s/^/`=newText`/
|
edit `=fname`
|
||||||
enddef
|
|
||||||
|
|
||||||
Or a script variable can be used: >
|
|
||||||
var newText = 'blah'
|
|
||||||
def Replace()
|
|
||||||
g/pattern/s/^/\=newText/
|
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
Closures defined in a loop will share the same context. For example: >
|
Closures defined in a loop will share the same context. For example: >
|
||||||
|
@@ -183,11 +183,18 @@ def Test_expand_alternate_file()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_global_backtick_expansion()
|
def Test_global_backtick_expansion()
|
||||||
|
var name = 'xxx'
|
||||||
new
|
new
|
||||||
setline(1, 'xx')
|
setline(1, ['one', 'two', 'three'])
|
||||||
var name = 'foobar'
|
set nomod
|
||||||
g/^xx/s/.*/`=name`
|
g/two/edit `=name`
|
||||||
assert_equal('foobar', getline(1))
|
assert_equal('xxx', bufname())
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
new
|
||||||
|
setline(1, ['one', 'two', 'three'])
|
||||||
|
g/two/s/^/`=name`/
|
||||||
|
assert_equal('`=name`two', getline(2))
|
||||||
bwipe!
|
bwipe!
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3710,
|
||||||
/**/
|
/**/
|
||||||
3709,
|
3709,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -9070,6 +9070,7 @@ compile_exec(char_u *line_arg, exarg_T *eap, cctx_T *cctx)
|
|||||||
int has_expr = FALSE;
|
int has_expr = FALSE;
|
||||||
char_u *nextcmd = (char_u *)"";
|
char_u *nextcmd = (char_u *)"";
|
||||||
char_u *tofree = NULL;
|
char_u *tofree = NULL;
|
||||||
|
char_u *cmd_arg = NULL;
|
||||||
|
|
||||||
if (cctx->ctx_skip == SKIP_YES)
|
if (cctx->ctx_skip == SKIP_YES)
|
||||||
goto theend;
|
goto theend;
|
||||||
@@ -9172,20 +9173,20 @@ compile_exec(char_u *line_arg, exarg_T *eap, cctx_T *cctx)
|
|||||||
|
|
||||||
p = skip_regexp_ex(eap->arg + 1, delim, TRUE, NULL, NULL, NULL);
|
p = skip_regexp_ex(eap->arg + 1, delim, TRUE, NULL, NULL, NULL);
|
||||||
if (*p == delim)
|
if (*p == delim)
|
||||||
{
|
cmd_arg = p + 1;
|
||||||
eap->arg = p + 1;
|
|
||||||
has_expr = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
|
if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
|
||||||
|
cmd_arg = eap->arg;
|
||||||
|
|
||||||
|
if (cmd_arg != NULL)
|
||||||
{
|
{
|
||||||
exarg_T nea;
|
exarg_T nea;
|
||||||
|
|
||||||
CLEAR_FIELD(nea);
|
CLEAR_FIELD(nea);
|
||||||
nea.cmd = eap->arg;
|
nea.cmd = cmd_arg;
|
||||||
p = find_ex_command(&nea, NULL, lookup_scriptitem, NULL);
|
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);
|
has_expr = excmd_get_argt(nea.cmdidx) & (EX_XFILE | EX_EXPAND);
|
||||||
if (has_expr)
|
if (has_expr)
|
||||||
|
Reference in New Issue
Block a user