patch 8.2.0567: Vim9: cannot put comments halfway expressions
Problem: Vim9: cannot put comments halfway expressions.
Solution: Support # comments in many places.
diff --git a/src/userfunc.c b/src/userfunc.c
index 98e1ec5..95483e2 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -154,6 +154,7 @@
int c;
int any_default = FALSE;
char_u *expr;
+ char_u *whitep = arg;
if (newargs != NULL)
ga_init2(newargs, (int)sizeof(char_u *), 3);
@@ -170,7 +171,8 @@
*/
while (*p != endchar)
{
- if (eap != NULL && *p == NUL && eap->getline != NULL)
+ while (eap != NULL && eap->getline != NULL
+ && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
{
char_u *theline;
@@ -180,6 +182,7 @@
break;
vim_free(*line_to_free);
*line_to_free = theline;
+ whitep = (char_u *)" ";
p = skipwhite(theline);
}
@@ -228,6 +231,7 @@
// find the end of the expression (doesn't evaluate it)
any_default = TRUE;
p = skipwhite(p) + 1;
+ whitep = p;
p = skipwhite(p);
expr = p;
if (eval1(&p, &rettv, FALSE) != FAIL)
@@ -264,6 +268,7 @@
else
mustend = TRUE;
}
+ whitep = p;
p = skipwhite(p);
}
@@ -2595,7 +2600,8 @@
// Makes 'exe "func Test()\n...\nendfunc"' work.
if (*p == '\n')
line_arg = p + 1;
- else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg)
+ else if (*p != NUL && *p != '"' && !(eap->cmdidx == CMD_def && *p == '#')
+ && !eap->skip && !did_emsg)
emsg(_(e_trailing));
/*