]> granicus.if.org Git - vim/commitdiff
patch 8.2.1243: Vim9: cannot have a comment line halfway a list v8.2.1243
authorBram Moolenaar <Bram@vim.org>
Sun, 19 Jul 2020 12:41:58 +0000 (14:41 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 Jul 2020 12:41:58 +0000 (14:41 +0200)
Problem:    Vim9: cannot have a comment or empty line halfway a list at script
            level.
Solution:   Skip more than one line if needed.

src/eval.c
src/proto/vim9compile.pro
src/scriptfile.c
src/version.c
src/vim9compile.c

index 9a9110efcd17084b1e8e1e89c646807bce484983..307a2aec7ddd12e156aa00c135f61a492a4ae767 100644 (file)
@@ -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;
 
index fb379239d13313b071b688de7d81a69503f887d6..30f7bbfb0e306aae3a853b5b87a4b012a8dd84a6 100644 (file)
@@ -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);
index 4e7df4d0d3218f7d99c2b0e68453d40e4219e071..55145733ec9df233008e2ed6002436da542a8701 100644 (file)
@@ -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);
index 2e8f4231d1a5ba40d53d72ee8762c442fa8f97fe..fb8fbe34607ceb69d000cf2888ccf793d7d51b56 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1243,
 /**/
     1242,
 /**/
index 81d5324cc8add9b80c1947173b6c05cdec77d75b..ed400769b1b1678792b6d0b2cd91f3bd9e23c4c7 100644 (file)
@@ -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] != '{';