Patch 9.0.0423
Problem:    "for" and "while" not recognized after :vim9cmd and :legacy.
            (Emanuele Torre)
Solution:   Recognize all the command modifiers. (closes #11087)
            Add a test to check the list of modifiers.
Files:      src/ex_docmd.c, src/testdir/test_eval_stuff.vim,
            src/testdir/test_cmdmods.vim, src/testdir/Make_all.mak


*** ../vim-9.0.0422/src/ex_docmd.c      2022-09-02 16:47:12.915042726 +0100
--- src/ex_docmd.c      2022-09-09 13:26:12.871752510 +0100
***************
*** 2888,2894 ****
  
        switch (*p)
        {
!           // When adding an entry, also modify cmd_exists().
            case 'a':   if (!checkforcmd_noparen(&eap->cmd, "aboveleft", 3))
                            break;
                        cmod->cmod_split |= WSP_ABOVE;
--- 2888,2894 ----
  
        switch (*p)
        {
!           // When adding an entry, also modify cmdmods[].
            case 'a':   if (!checkforcmd_noparen(&eap->cmd, "aboveleft", 3))
                            break;
                        cmod->cmod_split |= WSP_ABOVE;
***************
*** 3958,3968 ****
--- 3958,3970 ----
      {"confirm", 4, FALSE},
      {"filter", 4, FALSE},
      {"hide", 3, FALSE},
+     {"horizontal", 3, FALSE},
      {"keepalt", 5, FALSE},
      {"keepjumps", 5, FALSE},
      {"keepmarks", 3, FALSE},
      {"keeppatterns", 5, FALSE},
      {"leftabove", 5, FALSE},
+     {"legacy", 3, FALSE},
      {"lockmarks", 3, FALSE},
      {"noautocmd", 3, FALSE},
      {"noswapfile", 3, FALSE},
***************
*** 3974,3979 ****
--- 3976,3982 ----
      {"unsilent", 3, FALSE},
      {"verbose", 4, TRUE},
      {"vertical", 4, FALSE},
+     {"vim9cmd", 4, FALSE},
  };
  
  /*
*** ../vim-9.0.0422/src/testdir/test_eval_stuff.vim     2022-09-07 
21:30:40.143379043 +0100
--- src/testdir/test_eval_stuff.vim     2022-09-09 13:00:16.716188182 +0100
***************
*** 146,151 ****
--- 146,160 ----
    let &enc = save_enc
  endfunc
  
+ func Test_for_with_modifier()
+   " this checks has_loop_cmd() works with a modifier
+   let result = []
+   vim9cmd for i in range(3)
+     call extend(result, [i])
+   endfor
+   call assert_equal([0, 1, 2], result)
+ endfunc
+ 
  func Test_for_invalid_line_count()
    let lines =<< trim END
        111111111111111111111111 for line in ['one']
*** ../vim-9.0.0422/src/testdir/test_cmdmods.vim        2022-09-09 
13:27:13.551604850 +0100
--- src/testdir/test_cmdmods.vim        2022-09-09 13:24:42.091975245 +0100
***************
*** 0 ****
--- 1,35 ----
+ " Test for all comand modifiers in 
+ 
+ def Test_cmdmods_array()
+   # Get all the command modifiers from ex_cmds.h.
+   var lines = readfile('../ex_cmds.h')->filter((_, l) => l =~ 
'ex_wrongmodifier,')
+   var cmds = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))
+ 
+   # :hide is both a command and a modifier
+   cmds->extend(['hide'])
+ 
+   # Get the entries of cmdmods[] in ex_docmd.c
+   edit ../ex_docmd.c
+   var top = search('^} cmdmods[') + 1
+   var bot = search('^};') - 1
+   lines = getline(top, bot)
+   var mods = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))
+ 
+   # Check the lists are equal.  Convert them to a dict to get a clearer error
+   # message.
+   var cmds_dict = {}
+   for v in cmds
+     cmds_dict[v] = 1
+   endfor
+   var mods_dict = {}
+   for v in mods
+     mods_dict[v] = 1
+   endfor
+   assert_equal(cmds_dict, mods_dict)
+ 
+   bwipe!
+ enddef
+ 
+ 
+ " vim: shiftwidth=2 sts=2 expandtab
+ 
*** ../vim-9.0.0422/src/testdir/Make_all.mak    2022-07-23 06:24:56.405106035 
+0100
--- src/testdir/Make_all.mak    2022-09-09 13:11:48.638050145 +0100
***************
*** 87,92 ****
--- 87,93 ----
        test_clientserver \
        test_close_count \
        test_cmdline \
+       test_cmdmods \
        test_cmdwin \
        test_command_count \
        test_comments \
***************
*** 346,351 ****
--- 347,353 ----
        test_clientserver.res \
        test_close_count.res \
        test_cmdline.res \
+       test_cmdmods.res \
        test_cmdwin.res \
        test_command_count.res \
        test_comments.res \
*** ../vim-9.0.0422/src/version.c       2022-09-09 11:27:55.102727637 +0100
--- src/version.c       2022-09-09 13:17:21.241104718 +0100
***************
*** 705,706 ****
--- 705,708 ----
  {   /* Add new patch number below this line */
+ /**/
+     423,
  /**/

-- 
The only backup you need is the one that you didn't have time for.
(Murphy)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220909122829.87E341C0CF3%40moolenaar.net.

Raspunde prin e-mail lui