Patch 8.2.1838

6 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 11, 2020, 3:35:38 PM10/11/20
to vim...@googlegroups.com

Patch 8.2.1838
Problem: Vim9: cannot insert a comment line in an expression.
Solution: Skip comment lines at the script level. (closes #7111)
Files: src/eval.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1837/src/eval.c 2020-10-10 14:12:58.024646147 +0200
--- src/eval.c 2020-10-11 21:20:33.830616663 +0200
***************
*** 1968,1973 ****
--- 1968,1996 ----
}

/*
+ * Get the next line source line without advancing. But do skip over comment
+ * lines.
+ */
+ static char_u *
+ getline_peek_skip_comments(evalarg_T *evalarg)
+ {
+ for (;;)
+ {
+ char_u *next = getline_peek(evalarg->eval_getline,
+ evalarg->eval_cookie);
+ char_u *p;
+
+ if (next == NULL)
+ break;
+ p = skipwhite(next);
+ if (*p != NUL && !vim9_comment_start(p))
+ return next;
+ (void)eval_next_line(evalarg);
+ }
+ return NULL;
+ }
+
+ /*
* If inside Vim9 script, "arg" points to the end of a line (ignoring a #
* comment) and there is a next line, return the next line (skipping blanks)
* and set "getnext".
***************
*** 1988,1994 ****
char_u *next;

if (evalarg->eval_cookie != NULL)
! next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
else
next = peek_next_line_from_context(evalarg->eval_cctx);

--- 2011,2017 ----
char_u *next;

if (evalarg->eval_cookie != NULL)
! next = getline_peek_skip_comments(evalarg);
else
next = peek_next_line_from_context(evalarg->eval_cctx);

*** ../vim-8.2.1837/src/testdir/test_vim9_expr.vim 2020-10-05 19:23:56.216436744 +0200
--- src/testdir/test_vim9_expr.vim 2020-10-11 21:32:25.683807747 +0200
***************
*** 90,95 ****
--- 90,105 ----
END
CheckScriptSuccess(lines)

+ lines =<< trim END
+ vim9script
+ var name = v:false ? # comment
+ 'yes' :
+ # comment
+ 'no' # comment
+ assert_equal('no', name)
+ END
+ CheckScriptSuccess(lines)
+
# check white space
lines =<< trim END
vim9script
***************
*** 279,284 ****
--- 289,305 ----
END
CheckScriptSuccess(lines)

+ lines =<< trim END
+ vim9script
+ var name = v:false || # comment
+ # comment
+ v:true ||
+ # comment
+ v:false # comment
+ assert_equal(v:true, name)
+ END
+ CheckScriptSuccess(lines)
+
# check white space
lines =<< trim END
vim9script
***************
*** 405,410 ****
--- 426,442 ----
END
CheckScriptSuccess(lines)

+ lines =<< trim END
+ vim9script
+ var name = v:true && # comment
+ # comment
+ v:true &&
+ # comment
+ v:true
+ assert_equal(v:true, name)
+ END
+ CheckScriptSuccess(lines)
+
# check white space
lines =<< trim END
vim9script
***************
*** 800,805 ****
--- 832,838 ----
lines =<< trim END
vim9script
var name = 123
+ # comment
!= 123
assert_equal(false, name)
END
***************
*** 824,829 ****
--- 857,872 ----

lines =<< trim END
vim9script
+ var list = [1, 2, 3]
+ var name = list # comment
+ # comment
+ is list
+ assert_equal(true, name)
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
var myblob = 0z1234
var name = myblob
isnot 0z11
***************
*** 1059,1064 ****
--- 1102,1117 ----

lines =<< trim END
vim9script
+ var name = 11 + # comment
+ 77 -
+ # comment
+ 22
+ assert_equal(66, name)
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
var name = 'one'
.. 'two'
assert_equal('onetwo', name)
***************
*** 1305,1310 ****
--- 1358,1374 ----

lines =<< trim END
vim9script
+ var name = 25
+ # comment
+
+ # comment
+ % 10
+ assert_equal(5, name)
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
var name = 11 *
22 /
3
***************
*** 1618,1623 ****
--- 1682,1693 ----
echo [1,
2] [3,
4]
+
+ echo [1, # comment
+ # comment
+ 2] [3,
+ # comment
+ 4]
END
CheckScriptSuccess(lines)

***************
*** 1832,1837 ****
--- 1902,1918 ----
'two': 2,
}
assert_equal({'one': 1, 'two': 2}, d)
+
+ d = { # comment
+ 'one':
+ # comment
+
+ 1,
+ # comment
+ # comment
+ 'two': 2,
+ }
+ assert_equal({'one': 1, 'two': 2}, d)
END
CheckScriptSuccess(lines)

*** ../vim-8.2.1837/src/version.c 2020-10-11 20:44:10.873134571 +0200
--- src/version.c 2020-10-11 21:09:55.016497909 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1838,
/**/

--
hundred-and-one symptoms of being an internet addict:
67. Your hard drive crashes. You haven't logged in for two hours. You start
to twitch. You pick up the phone and manually dial your ISP's access
number. You try to hum to communicate with the modem. You succeed.

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