forked from aniani/vim
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:
@@ -184,6 +184,19 @@ example, when a list spans multiple lines: >
|
|||||||
'one',
|
'one',
|
||||||
'two',
|
'two',
|
||||||
]
|
]
|
||||||
|
And when a dict spans multiple lines: >
|
||||||
|
let mydict = #{
|
||||||
|
one: 1,
|
||||||
|
two: 2,
|
||||||
|
}
|
||||||
|
Function call: >
|
||||||
|
let result = Func(
|
||||||
|
arg1,
|
||||||
|
arg2
|
||||||
|
)
|
||||||
|
|
||||||
|
Note that "enddef" cannot be used at the start of a continuation line, it ends
|
||||||
|
the current function.
|
||||||
|
|
||||||
|
|
||||||
No curly braces expansion ~
|
No curly braces expansion ~
|
||||||
|
@@ -636,16 +636,16 @@ enddef
|
|||||||
|
|
||||||
def Test_import_absolute()
|
def Test_import_absolute()
|
||||||
let import_lines = [
|
let import_lines = [
|
||||||
\ 'vim9script',
|
'vim9script',
|
||||||
\ 'import exported from "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim"',
|
'import exported from "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim"',
|
||||||
\ 'def UseExported()',
|
'def UseExported()',
|
||||||
\ ' g:imported_abs = exported',
|
' g:imported_abs = exported',
|
||||||
\ ' exported = 8888',
|
' exported = 8888',
|
||||||
\ ' g:imported_after = exported',
|
' g:imported_after = exported',
|
||||||
\ 'enddef',
|
'enddef',
|
||||||
\ 'UseExported()',
|
'UseExported()',
|
||||||
\ 'g:import_disassembled = execute("disass UseExported")',
|
'g:import_disassembled = execute("disass UseExported")',
|
||||||
\ ]
|
]
|
||||||
writefile(import_lines, 'Ximport_abs.vim')
|
writefile(import_lines, 'Ximport_abs.vim')
|
||||||
writefile(s:export_script_lines, 'Xexport_abs.vim')
|
writefile(s:export_script_lines, 'Xexport_abs.vim')
|
||||||
|
|
||||||
@@ -661,8 +661,8 @@ def Test_import_absolute()
|
|||||||
\ .. '3 STORESCRIPT exported in .*Xexport_abs.vim.*'
|
\ .. '3 STORESCRIPT exported in .*Xexport_abs.vim.*'
|
||||||
\ .. 'g:imported_after = exported.*'
|
\ .. 'g:imported_after = exported.*'
|
||||||
\ .. '4 LOADSCRIPT exported from .*Xexport_abs.vim.*'
|
\ .. '4 LOADSCRIPT exported from .*Xexport_abs.vim.*'
|
||||||
\ .. '5 STOREG g:imported_after.*'
|
\ .. '5 STOREG g:imported_after.*',
|
||||||
\, g:import_disassembled)
|
g:import_disassembled)
|
||||||
unlet g:imported_abs
|
unlet g:imported_abs
|
||||||
unlet g:import_disassembled
|
unlet g:import_disassembled
|
||||||
|
|
||||||
@@ -672,10 +672,10 @@ enddef
|
|||||||
|
|
||||||
def Test_import_rtp()
|
def Test_import_rtp()
|
||||||
let import_lines = [
|
let import_lines = [
|
||||||
\ 'vim9script',
|
'vim9script',
|
||||||
\ 'import exported from "Xexport_rtp.vim"',
|
'import exported from "Xexport_rtp.vim"',
|
||||||
\ 'g:imported_rtp = exported',
|
'g:imported_rtp = exported',
|
||||||
\ ]
|
]
|
||||||
writefile(import_lines, 'Ximport_rtp.vim')
|
writefile(import_lines, 'Ximport_rtp.vim')
|
||||||
mkdir('import')
|
mkdir('import')
|
||||||
writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
|
writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
|
||||||
@@ -988,6 +988,11 @@ def Test_automatic_line_continuation()
|
|||||||
three: 3 " comment
|
three: 3 " comment
|
||||||
}
|
}
|
||||||
assert_equal(#{one: 1, two: 2, three: 3}, mydict)
|
assert_equal(#{one: 1, two: 2, three: 3}, mydict)
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
['one', 'two', 'three'],
|
||||||
|
split('one two three')
|
||||||
|
)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Keep this last, it messes up highlighting.
|
" Keep this last, it messes up highlighting.
|
||||||
|
@@ -738,6 +738,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 */
|
||||||
|
/**/
|
||||||
|
561,
|
||||||
/**/
|
/**/
|
||||||
560,
|
560,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2048,6 +2048,27 @@ free_imported(cctx_T *cctx)
|
|||||||
ga_clear(&cctx->ctx_imports);
|
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
|
* Generate an instruction to load script-local variable "name", without the
|
||||||
* leading "s:".
|
* leading "s:".
|
||||||
@@ -2284,8 +2305,21 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
|
|||||||
{
|
{
|
||||||
char_u *p = *arg;
|
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)
|
if (compile_expr1(&p, cctx) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
++*argcount;
|
++*argcount;
|
||||||
@@ -2298,19 +2332,14 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
|
|||||||
if (*p == ',')
|
if (*p == ',')
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
if (!VIM_ISWHITE(*p))
|
if (*p != NUL && !VIM_ISWHITE(*p))
|
||||||
semsg(_(e_white_after), ",");
|
semsg(_(e_white_after), ",");
|
||||||
}
|
}
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
}
|
}
|
||||||
p = skipwhite(p);
|
|
||||||
if (*p != ')')
|
emsg(_(e_missing_close));
|
||||||
{
|
return FAIL;
|
||||||
emsg(_(e_missing_close));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
*arg = p + 1;
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2534,27 +2563,6 @@ need_type(type_T *actual, type_T *expected, int offset, cctx_T *cctx)
|
|||||||
return OK;
|
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]
|
* parse a list: [expr, expr]
|
||||||
* "*arg" points to the '['.
|
* "*arg" points to the '['.
|
||||||
|
Reference in New Issue
Block a user