forked from aniani/vim
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Problem: Vim9: cannot use :command or :au with a block in a :def function. Solution: Recognize the start of the block.
This commit is contained in:
@@ -8861,11 +8861,13 @@ compile_put(char_u *arg, exarg_T *eap, cctx_T *cctx)
|
||||
* A command that is not compiled, execute with legacy code.
|
||||
*/
|
||||
static char_u *
|
||||
compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
|
||||
compile_exec(char_u *line_arg, exarg_T *eap, cctx_T *cctx)
|
||||
{
|
||||
char_u *line = line_arg;
|
||||
char_u *p;
|
||||
int has_expr = FALSE;
|
||||
char_u *nextcmd = (char_u *)"";
|
||||
char_u *tofree = NULL;
|
||||
|
||||
if (cctx->ctx_skip == SKIP_YES)
|
||||
goto theend;
|
||||
@@ -8922,6 +8924,34 @@ compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
|
||||
nextcmd = p + 1;
|
||||
}
|
||||
}
|
||||
else if (eap->cmdidx == CMD_command || eap->cmdidx == CMD_autocmd)
|
||||
{
|
||||
// If there is a trailing '{' read lines until the '}'
|
||||
p = eap->arg + STRLEN(eap->arg) - 1;
|
||||
while (p > eap->arg && VIM_ISWHITE(*p))
|
||||
--p;
|
||||
if (*p == '{')
|
||||
{
|
||||
exarg_T ea;
|
||||
int flags; // unused
|
||||
int start_lnum = SOURCING_LNUM;
|
||||
|
||||
CLEAR_FIELD(ea);
|
||||
ea.arg = eap->arg;
|
||||
fill_exarg_from_cctx(&ea, cctx);
|
||||
(void)may_get_cmd_block(&ea, p, &tofree, &flags);
|
||||
if (tofree != NULL)
|
||||
{
|
||||
*p = NUL;
|
||||
line = concat_str(line, tofree);
|
||||
if (line == NULL)
|
||||
goto theend;
|
||||
vim_free(tofree);
|
||||
tofree = line;
|
||||
SOURCING_LNUM = start_lnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (eap->cmdidx == CMD_syntax && STRNCMP(eap->arg, "include ", 8) == 0)
|
||||
@@ -9008,6 +9038,7 @@ theend:
|
||||
--nextcmd;
|
||||
*nextcmd = '|';
|
||||
}
|
||||
vim_free(tofree);
|
||||
|
||||
return nextcmd;
|
||||
}
|
||||
|
Reference in New Issue
Block a user