diff src/eval.c @ 22580:eb54d34ecd27 v8.2.1838

patch 8.2.1838: Vim9: cannot insert a comment line in an expression Commit: https://github.com/vim/vim/commit/93be1644db2848659b0610477968c83f53619da1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 11 21:34:41 2020 +0200 patch 8.2.1838: Vim9: cannot insert a comment line in an expression Problem: Vim9: cannot insert a comment line in an expression. Solution: Skip comment lines at the script level. (closes https://github.com/vim/vim/issues/7111)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Oct 2020 21:45:03 +0200
parents 7d6ba4204f66
children 336ac63fb987
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1968,6 +1968,29 @@ eval_func(
 }
 
 /*
+ * 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,7 +2011,7 @@ eval_next_non_blank(char_u *arg, evalarg
 	char_u *next;
 
 	if (evalarg->eval_cookie != NULL)
-	    next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
+	    next = getline_peek_skip_comments(evalarg);
 	else
 	    next = peek_next_line_from_context(evalarg->eval_cctx);