mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.1.0263: Vim9: Problem with lambda blocks in enums and classes
Problem: Vim9: Problem with lambda blocks in enums and classes (Aliaksei Budavei) Solution: Support evaluating lambda blocks from a string, skip over comments (Yegappan Lakshmanan) fixes: #14350 closes: #14405 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
4a65391ca2
commit
3fa8f7728a
@@ -1335,6 +1335,7 @@ lambda_function_body(
|
||||
char_u *name;
|
||||
int lnum_save = -1;
|
||||
linenr_T sourcing_lnum_top = SOURCING_LNUM;
|
||||
char_u *line_arg = NULL;
|
||||
|
||||
*arg = skipwhite(*arg + 1);
|
||||
if (**arg == '|' || !ends_excmd2(start, *arg))
|
||||
@@ -1343,6 +1344,12 @@ lambda_function_body(
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// When there is a line break use what follows for the lambda body.
|
||||
// Makes lambda body initializers work for object and enum member
|
||||
// variables.
|
||||
if (**arg == '\n')
|
||||
line_arg = *arg + 1;
|
||||
|
||||
CLEAR_FIELD(eap);
|
||||
eap.cmdidx = CMD_block;
|
||||
eap.forceit = FALSE;
|
||||
@@ -1357,7 +1364,7 @@ lambda_function_body(
|
||||
}
|
||||
|
||||
ga_init2(&newlines, sizeof(char_u *), 10);
|
||||
if (get_function_body(&eap, &newlines, NULL,
|
||||
if (get_function_body(&eap, &newlines, line_arg,
|
||||
&evalarg->eval_tofree_ga) == FAIL)
|
||||
goto erret;
|
||||
|
||||
@@ -1372,7 +1379,12 @@ lambda_function_body(
|
||||
|
||||
for (idx = 0; idx < newlines.ga_len; ++idx)
|
||||
{
|
||||
char_u *p = skipwhite(((char_u **)newlines.ga_data)[idx]);
|
||||
char_u *p = ((char_u **)newlines.ga_data)[idx];
|
||||
if (p == NULL)
|
||||
// comment line in the lambda body
|
||||
continue;
|
||||
|
||||
p = skipwhite(p);
|
||||
|
||||
if (ga_grow(gap, 1) == FAIL || ga_grow(freegap, 1) == FAIL)
|
||||
goto erret;
|
||||
|
Reference in New Issue
Block a user