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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220506205252.F26E11C03B1%40moolenaar.net.

Raspunde prin e-mail lui