mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 8.2.4897: comment inside an expression in lambda ignores the rest
Problem: Comment inside an expression in lambda ignores the rest of the expression. Solution: Truncate the line at the comment. (closes #10367)
This commit is contained in:
parent
a13e7acba9
commit
39be4981cd
11
src/eval.c
11
src/eval.c
@ -2208,8 +2208,15 @@ eval_next_line(char_u *arg, evalarg_T *evalarg)
|
|||||||
garray_T *gap = &evalarg->eval_ga;
|
garray_T *gap = &evalarg->eval_ga;
|
||||||
char_u *line;
|
char_u *line;
|
||||||
|
|
||||||
if (arg != NULL && *arg == NL)
|
if (arg != NULL)
|
||||||
return skipwhite(arg + 1);
|
{
|
||||||
|
if (*arg == NL)
|
||||||
|
return skipwhite(arg + 1);
|
||||||
|
// Truncate before a trailing comment, so that concatenating the lines
|
||||||
|
// won't turn the rest into a comment.
|
||||||
|
if (*skipwhite(arg) == '#')
|
||||||
|
*arg = NUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (evalarg->eval_cookie != NULL)
|
if (evalarg->eval_cookie != NULL)
|
||||||
line = evalarg->eval_getline(0, evalarg->eval_cookie, 0,
|
line = evalarg->eval_getline(0, evalarg->eval_cookie, 0,
|
||||||
|
@ -70,6 +70,16 @@ func Test_lambda_vim9cmd_linebreak()
|
|||||||
exe 'sleep ' .. [20, 100, 500, 500, 500][g:run_nr] .. 'm'
|
exe 'sleep ' .. [20, 100, 500, 500, 500][g:run_nr] .. 'm'
|
||||||
call assert_equal('done', g:result)
|
call assert_equal('done', g:result)
|
||||||
unlet g:result
|
unlet g:result
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
g:result = [0]->map((_, v) =>
|
||||||
|
1 # inline comment
|
||||||
|
+
|
||||||
|
2
|
||||||
|
)
|
||||||
|
assert_equal([3], g:result)
|
||||||
|
END
|
||||||
|
call v9.CheckDefAndScriptSuccess(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_lambda_with_partial()
|
func Test_lambda_with_partial()
|
||||||
|
@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
4897,
|
||||||
/**/
|
/**/
|
||||||
4896,
|
4896,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user