]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1588: Vim9: cannot split dict inside command block v9.1.1588
authorYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 25 Jul 2025 16:23:58 +0000 (18:23 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 25 Jul 2025 16:23:58 +0000 (18:23 +0200)
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 <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/dict.c
src/testdir/test_vim9_script.vim
src/version.c

index d43ca863e917667829f98d817cd5c7584c0e88bd..5339bb52cd973d0e4a61ab1d620a365bcbd2cee9 100644 (file)
@@ -1075,12 +1075,12 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
        had_comma = **arg == ',';
        if (had_comma)
        {
-           if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
+           if (vim9script && !IS_WHITE_NL_OR_NUL((*arg)[1]))
            {
                semsg(_(e_white_space_required_after_str_str), ",", *arg);
                goto failret;
            }
-           *arg = skipwhite(*arg + 1);
+           *arg = skipwhite_and_nl(*arg + 1);
        }
 
        // the "}" can be on the next line
index 0008f1e51d095f5fd2b6fa0d37b131eeda8ac71d..8e968d6efb8ea589a2962ee3bfa6ab054b95da6d 100644 (file)
@@ -5457,6 +5457,22 @@ def Test_if_cond_shortcircuit_skip_indexing()
   v9.CheckSourceSuccess(lines)
 enddef
 
+" Test for defining a dict with multiple keys in a command-block
+def Test_multikey_dict_in_block()
+  var lines =<< trim END
+    vim9script
+    command NewCommand {
+         g:TestDict = {
+           'key': 'v1',
+           'other_key': 'v2' }
+       }
+    NewCommand
+  END
+  v9.CheckSourceSuccess(lines)
+  assert_equal({key: 'v1', other_key: 'v2'}, g:TestDict)
+  unlet g:TestDict
+enddef
+
 " Keep this last, it messes up highlighting.
 def Test_substitute_cmd()
   new
index 16148447b0517d0f6ff91e9e041b5fb619c9e511..e9e601aa2270505496ff3d30229c67eb1aaff762 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1588,
 /**/
     1587,
 /**/