Skip to content

Commit a566a78

Browse files
yegappanchrisbra
authored andcommitted
patch 9.1.1588: Vim9: cannot split dict inside command block
Problem: Vim9: cannot split dict inside command block (lacygoill) Solution: Remove the current restriction (Yegappan Lakshmanan). fixes: #17841 closes: #17845 Signed-off-by: Yegappan Lakshmanan <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 0bda783 commit a566a78

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/dict.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,12 +1075,12 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
10751075
had_comma = **arg == ',';
10761076
if (had_comma)
10771077
{
1078-
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
1078+
if (vim9script && !IS_WHITE_NL_OR_NUL((*arg)[1]))
10791079
{
10801080
semsg(_(e_white_space_required_after_str_str), ",", *arg);
10811081
goto failret;
10821082
}
1083-
*arg = skipwhite(*arg + 1);
1083+
*arg = skipwhite_and_nl(*arg + 1);
10841084
}
10851085

10861086
// the "}" can be on the next line

src/testdir/test_vim9_script.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5457,6 +5457,22 @@ def Test_if_cond_shortcircuit_skip_indexing()
54575457
v9.CheckSourceSuccess(lines)
54585458
enddef
54595459

5460+
" Test for defining a dict with multiple keys in a command-block
5461+
def Test_multikey_dict_in_block()
5462+
var lines =<< trim END
5463+
vim9script
5464+
command NewCommand {
5465+
g:TestDict = {
5466+
'key': 'v1',
5467+
'other_key': 'v2' }
5468+
}
5469+
NewCommand
5470+
END
5471+
v9.CheckSourceSuccess(lines)
5472+
assert_equal({key: 'v1', other_key: 'v2'}, g:TestDict)
5473+
unlet g:TestDict
5474+
enddef
5475+
54605476
" Keep this last, it messes up highlighting.
54615477
def Test_substitute_cmd()
54625478
new

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1588,
722724
/**/
723725
1587,
724726
/**/

0 commit comments

Comments
 (0)