summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-17 14:46:12 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-17 14:46:12 +0000
commit02929a372e5e14db1b85abdc7d4515d6b2d81888 (patch)
treec14cee53f2230ca5102b8fff1d49c5fb393b4a3e
parent259f443a934c6f2447a14bfe54403903416a9af0 (diff)
downloadvim-git-8.2.3836.tar.gz
patch 8.2.3836: Vim9: comment after expression not skipped to find NLv8.2.3836
Problem: Vim9: comment after expression not skipped to find NL. Solution: After evaluating an expression look for a newline after a # comment.
-rw-r--r--src/eval.c23
-rw-r--r--src/version.c2
2 files changed, 23 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c
index 61bbb1d6e..f45cd8e77 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2222,16 +2222,35 @@ eval0(
{
int ret;
char_u *p;
+ char_u *expr_end;
int did_emsg_before = did_emsg;
int called_emsg_before = called_emsg;
int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
+ int check_for_end = TRUE;
int end_error = FALSE;
p = skipwhite(arg);
ret = eval1(&p, rettv, evalarg);
+ expr_end = p;
p = skipwhite(p);
- if (ret != FAIL)
+ // In Vim9 script a command block is not split at NL characters for
+ // commands using an expression argument. Skip over a '#' comment to check
+ // for a following NL. Require white space before the '#'.
+ if (in_vim9script() && p > expr_end)
+ while (*p == '#')
+ {
+ char_u *nl = vim_strchr(p, NL);
+
+ if (nl == NULL)
+ break;
+ p = skipwhite(nl + 1);
+ if (eap != NULL && *p != NUL)
+ eap->nextcmd = p;
+ check_for_end = FALSE;
+ }
+
+ if (ret != FAIL && check_for_end)
end_error = !ends_excmd2(arg, p);
if (ret == FAIL || end_error)
{
@@ -2263,7 +2282,7 @@ eval0(
return FAIL;
}
- if (eap != NULL)
+ if (check_for_end && eap != NULL)
set_nextcmd(eap, p);
return ret;
diff --git a/src/version.c b/src/version.c
index 7b2c48459..22f97ea21 100644
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3836,
+/**/
3835,
/**/
3834,