0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.0561: Vim9: cannot split function call in multiple lines

Problem:    Vim9: cannot split function call in multiple lines.
Solution:   Find more arguments in following lines.
This commit is contained in:
Bram Moolenaar
2020-04-12 20:19:16 +02:00
parent 2196bce56f
commit e6085c5350
4 changed files with 75 additions and 47 deletions

View File

@@ -2048,6 +2048,27 @@ free_imported(cctx_T *cctx)
ga_clear(&cctx->ctx_imports);
}
/*
* Get the next line of the function from "cctx".
* Returns NULL when at the end.
*/
static char_u *
next_line_from_context(cctx_T *cctx)
{
char_u *line = NULL;
do
{
++cctx->ctx_lnum;
if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len)
break;
line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum];
SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum
+ cctx->ctx_lnum + 1;
} while (line == NULL);
return line;
}
/*
* Generate an instruction to load script-local variable "name", without the
* leading "s:".
@@ -2284,8 +2305,21 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
{
char_u *p = *arg;
while (*p != NUL && *p != ')')
for (;;)
{
if (*p == NUL)
{
p = next_line_from_context(cctx);
if (p == NULL)
break;
p = skipwhite(p);
}
if (*p == ')')
{
*arg = p + 1;
return OK;
}
if (compile_expr1(&p, cctx) == FAIL)
return FAIL;
++*argcount;
@@ -2298,19 +2332,14 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
if (*p == ',')
{
++p;
if (!VIM_ISWHITE(*p))
if (*p != NUL && !VIM_ISWHITE(*p))
semsg(_(e_white_after), ",");
}
p = skipwhite(p);
}
p = skipwhite(p);
if (*p != ')')
{
emsg(_(e_missing_close));
return FAIL;
}
*arg = p + 1;
return OK;
emsg(_(e_missing_close));
return FAIL;
}
/*
@@ -2534,27 +2563,6 @@ need_type(type_T *actual, type_T *expected, int offset, cctx_T *cctx)
return OK;
}
/*
* Get the next line of the function from "cctx".
* Returns NULL when at the end.
*/
static char_u *
next_line_from_context(cctx_T *cctx)
{
char_u *line = NULL;
do
{
++cctx->ctx_lnum;
if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len)
break;
line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum];
SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum
+ cctx->ctx_lnum + 1;
} while (line == NULL);
return line;
}
/*
* parse a list: [expr, expr]
* "*arg" points to the '['.