0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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)
This commit is contained in:
Bram Moolenaar
2020-10-11 21:34:41 +02:00
parent c07b7f701f
commit 93be1644db
3 changed files with 107 additions and 1 deletions

View File

@@ -1967,6 +1967,29 @@ eval_func(
return ret;
}
/*
* 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)
@@ -1988,7 +2011,7 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
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);