Patch 8.2.2816
Problem: Vim9: comment below expression in lambda causes problems.
Solution: Use a single space for empty and comment lines. (closes #8156)
Files: src/eval.c, src/testdir/test_vim9_expr.vim
*** ../vim-8.2.2815/src/eval.c 2021-04-24 19:08:20.488010321 +0200
--- src/eval.c 2021-04-28 19:59:15.510610822 +0200
***************
*** 393,399 ****
}
/*
! * Skip over an expression at "*pp".
* If in Vim9 script and line breaks are encountered, the lines are
* concatenated. "evalarg->eval_tofree" will be set accordingly.
* "arg" is advanced to just after the expression.
--- 393,399 ----
}
/*
! * Skip over an expression at "*arg".
* If in Vim9 script and line breaks are encountered, the lines are
* concatenated. "evalarg->eval_tofree" will be set accordingly.
* "arg" is advanced to just after the expression.
***************
*** 451,457 ****
// Line breaks encountered, concatenate all the lines.
*((char_u **)gap->ga_data) = *start;
! p = ga_concat_strings(gap, "");
// free the lines only when using getsourceline()
if (evalarg->eval_cookie != NULL)
--- 451,457 ----
// Line breaks encountered, concatenate all the lines.
*((char_u **)gap->ga_data) = *start;
! p = ga_concat_strings(gap, " ");
// free the lines only when using getsourceline()
if (evalarg->eval_cookie != NULL)
***************
*** 2059,2064 ****
--- 2059,2065 ----
/*
* Get the next line source line without advancing. But do skip over comment
* lines.
+ * Only called for Vim9 script.
*/
static char_u *
getline_peek_skip_comments(evalarg_T *evalarg)
***************
*** 2116,2121 ****
--- 2117,2123 ----
/*
* To be called after eval_next_non_blank() sets "getnext" to TRUE.
+ * Only called for Vim9 script.
*/
char_u *
eval_next_line(evalarg_T *evalarg)
***************
*** 2131,2137 ****
++evalarg->eval_break_count;
if (gap->ga_itemsize > 0 && ga_grow(gap, 1) == OK)
{
! // Going to concatenate the lines after parsing.
((char_u **)gap->ga_data)[gap->ga_len] = line;
++gap->ga_len;
}
--- 2133,2148 ----
++evalarg->eval_break_count;
if (gap->ga_itemsize > 0 && ga_grow(gap, 1) == OK)
{
! char_u *p = skipwhite(line);
!
! // Going to concatenate the lines after parsing. For an empty or
! // comment line use an empty string.
! if (*p == NUL || vim9_comment_start(p))
! {
! vim_free(line);
! line = vim_strsave((char_u *)"");
! }
!
((char_u **)gap->ga_data)[gap->ga_len] = line;
++gap->ga_len;
}
*** ../vim-8.2.2815/src/testdir/test_vim9_expr.vim 2021-04-24
19:08:20.492010301 +0200
--- src/testdir/test_vim9_expr.vim 2021-04-28 19:43:20.341686168 +0200
***************
*** 1887,1892 ****
--- 1887,1893 ----
def Test_expr7_lambda()
var lines =<< trim END
var La = () => 'result'
+ # comment
assert_equal('result', La())
assert_equal([1, 3, 5], [1, 2, 3]->map((key, val) => key + val))
***************
*** 1897,1902 ****
--- 1898,1909 ----
)
assert_equal([{}, {111: 111}, {}], dll)
+ # comment halfway an expression
+ var Ref = () => 4
+ # comment
+ + 6
+ assert_equal(10, Ref())
+
ll = range(3)
map(ll, (k, v) => v == 8 || v
== 9
*** ../vim-8.2.2815/src/version.c 2021-04-27 20:06:52.635151858 +0200
--- src/version.c 2021-04-28 19:39:44.134386469 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2816,
/**/
--
A computer program does what you tell it to do, not what you want it to do.
/// 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/202104281801.13SI1AAb3049421%40masaka.moolenaar.net.