summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-15 15:41:44 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-15 15:41:44 +0000
commitce7eada12ea16c830332042f0021a9564bbb25af (patch)
treefce1a25ce1feba54a4f3e5154f3bd2200d133c20 /src
parentcfabad9bcf45650dee1f1f41ec4047f82a12f323 (diff)
downloadvim-git-ce7eada12ea16c830332042f0021a9564bbb25af.tar.gz
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a blockv8.2.3815
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.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c17
-rw-r--r--src/eval.c2
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/proto/charset.pro1
-rw-r--r--src/testdir/test_vim9_expr.vim14
-rw-r--r--src/version.c2
6 files changed, 34 insertions, 4 deletions
diff --git a/src/charset.c b/src/charset.c
index 0c17140c7..31b03eb38 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -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;
}
diff --git a/src/eval.c b/src/eval.c
index d9f44b2c8..bc5eaa4d6 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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);
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index c06a508ab..5f5240119 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -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;
diff --git a/src/proto/charset.pro b/src/proto/charset.pro
index c71188de3..ee5370bcc 100644
--- a/src/proto/charset.pro
+++ b/src/proto/charset.pro
@@ -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);
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 1f695bc70..e374788db 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 3395864fe..702913464 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 */
/**/
+ 3815,
+/**/
3814,
/**/
3813,