summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-19 14:41:58 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-19 14:41:58 +0200
commit75783bd84e42e8431e4a62dfbabc9be1a1e56901 (patch)
tree3c62a332de2eee53b4b7e936b19bd29961dd3250
parent65b9545f4494abcb455400c08e51de27bc305866 (diff)
patch 8.2.1243: Vim9: cannot have a comment line halfway a listv8.2.1243
Problem: Vim9: cannot have a comment or empty line halfway a list at script level. Solution: Skip more than one line if needed.
-rw-r--r--src/eval.c2
-rw-r--r--src/proto/vim9compile.pro1
-rw-r--r--src/scriptfile.c10
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c2
5 files changed, 13 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c
index 9a9110efcd..307a2aec7d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1913,7 +1913,7 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
&& evalarg != NULL
&& (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL)
&& (*arg == NUL || (VIM_ISWHITE(arg[-1])
- && *arg == '#' && arg[1] != '{')))
+ && vim9_comment_start(arg))))
{
char_u *p;
diff --git a/src/proto/vim9compile.pro b/src/proto/vim9compile.pro
index fb379239d1..30f7bbfb0e 100644
--- a/src/proto/vim9compile.pro
+++ b/src/proto/vim9compile.pro
@@ -11,6 +11,7 @@ char *vartype_name(vartype_T type);
char *type_name(type_T *type, char **tofree);
int get_script_item_idx(int sid, char_u *name, int check_writable);
imported_T *find_imported(char_u *name, size_t len, cctx_T *cctx);
+int vim9_comment_start(char_u *p);
char_u *peek_next_line_from_context(cctx_T *cctx);
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
char_u *to_name_const_end(char_u *arg);
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 4e7df4d0d3..55145733ec 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1763,10 +1763,13 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED, int do_concat)
// backslash. We always need to read the next line, keep it in
// sp->nextline.
/* Also check for a comment in between continuation lines: "\ */
+ // Also check for a Vim9 comment and empty line.
sp->nextline = get_one_sourceline(sp);
if (sp->nextline != NULL
&& (*(p = skipwhite(sp->nextline)) == '\\'
- || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')))
+ || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')
+ || (in_vim9script()
+ && (*p == NUL || vim9_comment_start(p)))))
{
garray_T ga;
@@ -1794,8 +1797,11 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED, int do_concat)
}
ga_concat(&ga, p + 1);
}
- else if (p[0] != '"' || p[1] != '\\' || p[2] != ' ')
+ else if (!(p[0] == '"' && p[1] == '\\' && p[2] == ' ')
+ && !(in_vim9script()
+ && (*p == NUL || vim9_comment_start(p))))
break;
+ /* drop a # comment or "\ comment line */
}
ga_append(&ga, NUL);
vim_free(line);
diff --git a/src/version.c b/src/version.c
index 2e8f4231d1..fb8fbe3460 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1243,
+/**/
1242,
/**/
1241,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 81d5324cc8..ed400769b1 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2463,7 +2463,7 @@ free_imported(cctx_T *cctx)
/*
* Return TRUE if "p" points at a "#" but not at "#{".
*/
- static int
+ int
vim9_comment_start(char_u *p)
{
return p[0] == '#' && p[1] != '{';