Patch 8.2.4897

4 views
Skip to first unread message

Bram Moolenaar

unread,
May 6, 2022, 4:52:59 PM5/6/22
to vim...@googlegroups.com

Patch 8.2.4897
Problem: Comment inside an expression in lambda ignores the rest of the
expression.
Solution: Truncate the line at the comment. (closes #10367)
Files: src/eval.c, src/testdir/test_lambda.vim


*** ../vim-8.2.4896/src/eval.c 2022-05-06 21:24:28.182534249 +0100
--- src/eval.c 2022-05-06 21:47:49.872392207 +0100
***************
*** 2208,2215 ****
garray_T *gap = &evalarg->eval_ga;
char_u *line;

! if (arg != NULL && *arg == NL)
! return skipwhite(arg + 1);

if (evalarg->eval_cookie != NULL)
line = evalarg->eval_getline(0, evalarg->eval_cookie, 0,
--- 2208,2222 ----
garray_T *gap = &evalarg->eval_ga;
char_u *line;

! if (arg != NULL)
! {
! 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)
line = evalarg->eval_getline(0, evalarg->eval_cookie, 0,
*** ../vim-8.2.4896/src/testdir/test_lambda.vim 2022-04-18 16:14:06.435897246 +0100
--- src/testdir/test_lambda.vim 2022-05-06 21:47:04.284442543 +0100
***************
*** 70,75 ****
--- 70,85 ----
exe 'sleep ' .. [20, 100, 500, 500, 500][g:run_nr] .. 'm'
call assert_equal('done', 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

func Test_lambda_with_partial()
*** ../vim-8.2.4896/src/version.c 2022-05-06 21:24:28.182534249 +0100
--- src/version.c 2022-05-06 21:44:39.196610935 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4897,
/**/

--
~
~
~
".signature" 4 lines, 50 characters written

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages