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 #7111)
diff --git a/src/eval.c b/src/eval.c
index 98d16c8..58d98e5 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1968,6 +1968,29 @@
}
/*
+ * 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 @@
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);