]> granicus.if.org Git - vim/commitdiff
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block v8.2.3815
authorBram Moolenaar <Bram@vim.org>
Wed, 15 Dec 2021 15:41:44 +0000 (15:41 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 15 Dec 2021 15:41:44 +0000 (15:41 +0000)
Problem:    Vim9: cannot have a multi-line dict inside a block.
Solution:   Do not split the command at a line break, handle NL characters
            as white space.

src/charset.c
src/eval.c
src/ex_docmd.c
src/proto/charset.pro
src/testdir/test_vim9_expr.vim
src/version.c

index 0c17140c75e3a2ebc616fa3bc84be21cf8313c3a..31b03eb38a15a342023f36f2b9037458a9d734ab 100644 (file)
@@ -1459,14 +1459,27 @@ getvcols(
 }
 
 /*
- * skipwhite: skip over ' ' and '\t'.
+ * Skip over ' ' and '\t'.
  */
     char_u *
 skipwhite(char_u *q)
 {
     char_u     *p = q;
 
-    while (VIM_ISWHITE(*p)) // skip to next non-white
+    while (VIM_ISWHITE(*p))
+       ++p;
+    return p;
+}
+
+/*
+ * skip over ' ', '\t' and '\n'.
+ */
+    char_u *
+skipwhite_and_nl(char_u *q)
+{
+    char_u     *p = q;
+
+    while (VIM_ISWHITE(*p) || *p == NL)
        ++p;
     return p;
 }
index d9f44b2c8087d0a98db517a4e7d78a7a7df93849..bc5eaa4d63157632381e414165d84e9061027faf 100644 (file)
@@ -2150,7 +2150,7 @@ eval_next_line(evalarg_T *evalarg)
 skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg)
 {
     int            getnext;
-    char_u  *p = skipwhite(arg);
+    char_u  *p = skipwhite_and_nl(arg);
 
     if (evalarg == NULL)
        return skipwhite(arg);
index c06a508abfa0d7b2708c9dd55c8a745fa2a1a04e..5f524011928ea96201dd8f83e361f4fa4dcdcb96 100644 (file)
@@ -2305,7 +2305,7 @@ do_one_cmd(
            // versions.
            if (*p == '\\' && p[1] == '\n')
                STRMOVE(p, p + 1);
-           else if (*p == '\n')
+           else if (*p == '\n' && (ea.argt & EX_TRLBAR))
            {
                ea.nextcmd = p + 1;
                *p = NUL;
index c71188de354a5105d4eaaa2fddbe425b948eed0a..ee5370bccdb6b841eb01917586811602bfc6c6f4 100644 (file)
@@ -36,6 +36,7 @@ colnr_T getvcol_nolist(pos_T *posp);
 void getvvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end);
 void getvcols(win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, colnr_T *right);
 char_u *skipwhite(char_u *q);
+char_u *skipwhite_and_nl(char_u *q);
 int getwhitecols_curline(void);
 int getwhitecols(char_u *p);
 char_u *skipdigits(char_u *q);
index 1f695bc7076e77153369c4d67094df5bf9a6ec49..e374788dba4eef77e6cfac72a43572bf9fd43a13 100644 (file)
@@ -2549,6 +2549,20 @@ def Test_expr7_dict_vim9script()
   CheckScriptSuccess(lines)
 enddef
 
+def Test_expr7_dict_in_block()
+  var lines =<< trim END
+      vim9script
+      command MyCommand {
+          echo {
+              k: 0, }
+      }
+      MyCommand
+  END
+  CheckScriptSuccess(lines)
+
+  delcommand MyCommand
+enddef
+
 def Test_expr7_call_2bool()
   var lines =<< trim END
       vim9script
index 3395864fe6755abb602aac89201cf436a143e6cd..702913464c02076704bb8048bb40235228fd96fa 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3815,
 /**/
     3814,
 /**/