Patch 8.2.3324
Problem:    Vim9: Cannot use :silent with :endwhile.
Solution:   Allow for using the :silent modifier. (closes #8737)
Files:      src/ex_eval.c, src/ex_docmd.c, src/proto/ex_docmd.pro,
            src/vim9compile.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.3323/src/ex_eval.c       2021-08-07 13:26:47.851191736 +0200
--- src/ex_eval.c       2021-08-09 22:39:36.962319376 +0200
***************
*** 1026,1032 ****
  {
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error())
        return;
      did_endif = TRUE;
      if (cstack->cs_idx < 0
--- 1026,1032 ----
  {
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error(FALSE))
        return;
      did_endif = TRUE;
      if (cstack->cs_idx < 0
***************
*** 1355,1361 ****
      int               csf;
      int               fl;
  
!     if (cmdmod_error())
        return;
  
      if (eap->cmdidx == CMD_endwhile)
--- 1355,1361 ----
      int               csf;
      int               fl;
  
!     if (cmdmod_error(TRUE))
        return;
  
      if (eap->cmdidx == CMD_endwhile)
***************
*** 1593,1599 ****
      int               skip;
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error())
        return;
  
      if (cstack->cs_idx == CSTACK_LEN - 1)
--- 1593,1599 ----
      int               skip;
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error(FALSE))
        return;
  
      if (cstack->cs_idx == CSTACK_LEN - 1)
***************
*** 1674,1680 ****
      cstack_T  *cstack = eap->cstack;
      char_u    *pat;
  
!     if (cmdmod_error())
        return;
  
      if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
--- 1674,1680 ----
      cstack_T  *cstack = eap->cstack;
      char_u    *pat;
  
!     if (cmdmod_error(FALSE))
        return;
  
      if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
***************
*** 1839,1845 ****
      int               pending = CSTP_NONE;
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error())
        return;
  
      if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
--- 1839,1845 ----
      int               pending = CSTP_NONE;
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error(FALSE))
        return;
  
      if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
***************
*** 1971,1977 ****
      void      *rettv = NULL;
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error())
        return;
  
      if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
--- 1971,1977 ----
      void      *rettv = NULL;
      cstack_T  *cstack = eap->cstack;
  
!     if (cmdmod_error(FALSE))
        return;
  
      if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
*** ../vim-8.2.3323/src/ex_docmd.c      2021-08-09 19:59:01.438811254 +0200
--- src/ex_docmd.c      2021-08-09 22:38:44.066416983 +0200
***************
*** 3061,3069 ****
   * Return TRUE if "cmod" has anything set.
   */
      int
! has_cmdmod(cmdmod_T *cmod)
  {
!     return cmod->cmod_flags != 0
            || cmod->cmod_split != 0
            || cmod->cmod_verbose != 0
            || cmod->cmod_tab != 0
--- 3061,3071 ----
   * Return TRUE if "cmod" has anything set.
   */
      int
! has_cmdmod(cmdmod_T *cmod, int ignore_silent)
  {
!     return (cmod->cmod_flags != 0 && (!ignore_silent
!               || (cmod->cmod_flags
!                     & ~(CMOD_SILENT | CMOD_ERRSILENT | CMOD_UNSILENT)) != 0))
            || cmod->cmod_split != 0
            || cmod->cmod_verbose != 0
            || cmod->cmod_tab != 0
***************
*** 3074,3082 ****
   * If Vim9 script and "cmdmod" has anything set give an error and return TRUE.
   */
      int
! cmdmod_error(void)
  {
!     if (in_vim9script() && has_cmdmod(&cmdmod))
      {
        emsg(_(e_misplaced_command_modifier));
        return TRUE;
--- 3076,3084 ----
   * If Vim9 script and "cmdmod" has anything set give an error and return TRUE.
   */
      int
! cmdmod_error(int ignore_silent)
  {
!     if (in_vim9script() && has_cmdmod(&cmdmod, ignore_silent))
      {
        emsg(_(e_misplaced_command_modifier));
        return TRUE;
*** ../vim-8.2.3323/src/proto/ex_docmd.pro      2021-08-09 19:59:01.442811242 
+0200
--- src/proto/ex_docmd.pro      2021-08-09 22:39:41.714310468 +0200
***************
*** 10,17 ****
  int checkforcmd(char_u **pp, char *cmd, int len);
  int checkforcmd_noparen(char_u **pp, char *cmd, int len);
  int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, 
int skip_only);
! int has_cmdmod(cmdmod_T *cmod);
! int cmdmod_error(void);
  void apply_cmdmod(cmdmod_T *cmod);
  void undo_cmdmod(cmdmod_T *cmod);
  int parse_cmd_address(exarg_T *eap, char **errormsg, int silent);
--- 10,17 ----
  int checkforcmd(char_u **pp, char *cmd, int len);
  int checkforcmd_noparen(char_u **pp, char *cmd, int len);
  int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, 
int skip_only);
! int has_cmdmod(cmdmod_T *cmod, int ignore_silent);
! int cmdmod_error(int ignore_silent);
  void apply_cmdmod(cmdmod_T *cmod);
  void undo_cmdmod(cmdmod_T *cmod);
  int parse_cmd_address(exarg_T *eap, char **errormsg, int silent);
***************
*** 32,38 ****
  int ends_excmd2(char_u *cmd_start, char_u *cmd);
  char_u *find_nextcmd(char_u *p);
  char_u *check_nextcmd(char_u *p);
! void set_nextcmd(exarg_T *eap, char_u *p);
  char_u *get_command_name(expand_T *xp, int idx);
  void not_exiting(void);
  int before_quit_autocmds(win_T *wp, int quit_all, int forceit);
--- 32,38 ----
  int ends_excmd2(char_u *cmd_start, char_u *cmd);
  char_u *find_nextcmd(char_u *p);
  char_u *check_nextcmd(char_u *p);
! void set_nextcmd(exarg_T *eap, char_u *arg);
  char_u *get_command_name(expand_T *xp, int idx);
  void not_exiting(void);
  int before_quit_autocmds(win_T *wp, int quit_all, int forceit);
*** ../vim-8.2.3323/src/vim9compile.c   2021-08-09 19:59:01.446811234 +0200
--- src/vim9compile.c   2021-08-09 22:37:07.546586898 +0200
***************
*** 2344,2350 ****
  {
      isn_T     *isn;
  
!     if (has_cmdmod(cmod))
      {
        cctx->ctx_has_cmdmod = TRUE;
  
--- 2344,2350 ----
  {
      isn_T     *isn;
  
!     if (has_cmdmod(cmod, FALSE))
      {
        cctx->ctx_has_cmdmod = TRUE;
  
*** ../vim-8.2.3323/src/testdir/test_vim9_cmd.vim       2021-08-02 
22:26:52.014701338 +0200
--- src/testdir/test_vim9_cmd.vim       2021-08-09 22:48:40.957195963 +0200
***************
*** 807,812 ****
--- 807,823 ----
      echomsg "caught"
    endtry
    assert_equal("\ncaught", execute(':1messages'))
+ 
+   var lines =<< trim END
+       vim9script
+       set history=11
+       silent! while 0
+         set history=22
+       silent! endwhile
+       assert_equal(11, &history)
+       set history&
+   END
+   CheckScriptSuccess(lines)
  enddef
  
  def Test_range_after_command_modifier()
***************
*** 836,848 ****
        for i in [0]
        silent endfor
    END
!   CheckDefAndScriptFailure(lines, 'E1176:', 2)
  
    lines =<< trim END
        while g:maybe
        silent endwhile
    END
!   CheckDefAndScriptFailure(lines, 'E1176:', 2)
  
    lines =<< trim END
        silent try
--- 847,862 ----
        for i in [0]
        silent endfor
    END
!   CheckDefFailure(lines, 'E1176:', 2)
!   CheckScriptSuccess(['vim9script'] + lines)
  
    lines =<< trim END
        while g:maybe
        silent endwhile
    END
!   CheckDefFailure(lines, 'E1176:', 2)
!   g:maybe = false
!   CheckScriptSuccess(['vim9script'] + lines)
  
    lines =<< trim END
        silent try
*** ../vim-8.2.3323/src/version.c       2021-08-10 10:23:22.280476685 +0200
--- src/version.c       2021-08-10 19:52:29.786298347 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3324,
  /**/

-- 
The early bird gets the worm. The second mouse gets the cheese.

 /// 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/202108101753.17AHrOsh2709985%40masaka.moolenaar.net.

Raspunde prin e-mail lui