Patch 8.1.2017
Problem:    Cannot execute commands after closing the cmdline window.
Solution:   Also trigger BufEnter and WinEnter. (closes #4762)
Files:      runtime/doc/autocmd.txt, runtime/doc/cmdline.txt, src/ex_getln.c,
            src/testdir/test_cmdline.vim


*** ../vim-8.1.2016/runtime/doc/autocmd.txt     2019-08-17 19:36:01.202907209 
+0200
--- runtime/doc/autocmd.txt     2019-09-09 17:56:36.474315904 +0200
***************
*** 554,569 ****
                                                        *CmdwinEnter*
  CmdwinEnter                   After entering the command-line window.
                                Useful for setting options specifically for
!                               this special type of window.  This is
!                               triggered _instead_ of BufEnter and WinEnter.
                                <afile> is set to a single character,
                                indicating the type of command-line.
                                |cmdwin-char|
                                                        *CmdwinLeave*
  CmdwinLeave                   Before leaving the command-line window.
                                Useful to clean up any global setting done
!                               with CmdwinEnter.  This is triggered _instead_
!                               of BufLeave and WinLeave.
                                <afile> is set to a single character,
                                indicating the type of command-line.
                                |cmdwin-char|
--- 554,567 ----
                                                        *CmdwinEnter*
  CmdwinEnter                   After entering the command-line window.
                                Useful for setting options specifically for
!                               this special type of window.
                                <afile> is set to a single character,
                                indicating the type of command-line.
                                |cmdwin-char|
                                                        *CmdwinLeave*
  CmdwinLeave                   Before leaving the command-line window.
                                Useful to clean up any global setting done
!                               with CmdwinEnter.
                                <afile> is set to a single character,
                                indicating the type of command-line.
                                |cmdwin-char|
*** ../vim-8.1.2016/runtime/doc/cmdline.txt     2019-08-18 22:25:54.669447972 
+0200
--- runtime/doc/cmdline.txt     2019-09-09 17:56:36.474315904 +0200
***************
*** 1172,1182 ****
  
  AUTOCOMMANDS
  
! Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|.  Since this
! window is of a special type, the WinEnter, WinLeave, BufEnter and BufLeave
! events are not triggered.  You can use the Cmdwin events to do settings
! specifically for the command-line window.  Be careful not to cause side
! effects!
  Example: >
        :au CmdwinEnter :  let b:cpt_save = &cpt | set cpt=.
        :au CmdwinLeave :  let &cpt = b:cpt_save
--- 1171,1179 ----
  
  AUTOCOMMANDS
  
! Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|.  You can use
! the Cmdwin events to do settings specifically for the command-line window.
! Be careful not to cause side effects!
  Example: >
        :au CmdwinEnter :  let b:cpt_save = &cpt | set cpt=.
        :au CmdwinLeave :  let &cpt = b:cpt_save
*** ../vim-8.1.2016/src/ex_getln.c      2019-09-04 17:48:11.712877356 +0200
--- src/ex_getln.c      2019-09-09 18:01:46.157215953 +0200
***************
*** 4069,4098 ****
      }
      set_bufref(&old_curbuf, curbuf);
  
!     /* Save current window sizes. */
      win_size_save(&winsizes);
  
-     /* Don't execute autocommands while creating the window. */
-     block_autocmds();
- 
      // When using completion in Insert mode with <C-R>=<C-F> one can open the
      // command line window, but we don't want the popup menu then.
      pum_undisplay();
  
!     /* don't use a new tab page */
      cmdmod.tab = 0;
      cmdmod.noswapfile = 1;
  
!     /* Create a window for the command-line buffer. */
      if (win_split((int)p_cwh, WSP_BOT) == FAIL)
      {
        beep_flush();
-       unblock_autocmds();
        return K_IGNORE;
      }
      cmdwin_type = get_cmdline_type();
  
!     /* Create the command-line buffer empty. */
      (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
      (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
      set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
--- 4069,4094 ----
      }
      set_bufref(&old_curbuf, curbuf);
  
!     // Save current window sizes.
      win_size_save(&winsizes);
  
      // When using completion in Insert mode with <C-R>=<C-F> one can open the
      // command line window, but we don't want the popup menu then.
      pum_undisplay();
  
!     // don't use a new tab page
      cmdmod.tab = 0;
      cmdmod.noswapfile = 1;
  
!     // Create a window for the command-line buffer.
      if (win_split((int)p_cwh, WSP_BOT) == FAIL)
      {
        beep_flush();
        return K_IGNORE;
      }
      cmdwin_type = get_cmdline_type();
  
!     // Create the command-line buffer empty.
      (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
      (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
      set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
***************
*** 4106,4117 ****
  # endif
      RESET_BINDING(curwin);
  
!     /* Do execute autocommands for setting the filetype (load syntax). */
!     unblock_autocmds();
!     /* But don't allow switching to another buffer. */
      ++curbuf_lock;
  
!     /* Showing the prompt may have set need_wait_return, reset it. */
      need_wait_return = FALSE;
  
      histtype = hist_char2type(cmdwin_type);
--- 4102,4111 ----
  # endif
      RESET_BINDING(curwin);
  
!     // Don't allow switching to another buffer.
      ++curbuf_lock;
  
!     // Showing the prompt may have set need_wait_return, reset it.
      need_wait_return = FALSE;
  
      histtype = hist_char2type(cmdwin_type);
***************
*** 4126,4136 ****
      }
      --curbuf_lock;
  
!     /* Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin
!      * sets 'textwidth' to 78). */
      curbuf->b_p_tw = 0;
  
!     /* Fill the buffer with the history. */
      init_history();
      if (get_hislen() > 0)
      {
--- 4120,4130 ----
      }
      --curbuf_lock;
  
!     // Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin
!     // sets 'textwidth' to 78).
      curbuf->b_p_tw = 0;
  
!     // Fill the buffer with the history.
      init_history();
      if (get_hislen() > 0)
      {
***************
*** 4167,4175 ****
      setmouse();
  # endif
  
!     /* Trigger CmdwinEnter autocommands. */
      trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER);
!     if (restart_edit != 0)    /* autocmd with ":startinsert" */
        stuffcharReadbuff(K_NOP);
  
      i = RedrawingDisabled;
--- 4161,4169 ----
      setmouse();
  # endif
  
!     // Trigger CmdwinEnter autocommands.
      trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER);
!     if (restart_edit != 0)    // autocmd with ":startinsert"
        stuffcharReadbuff(K_NOP);
  
      i = RedrawingDisabled;
***************
*** 4187,4197 ****
      save_KeyTyped = KeyTyped;
  # endif
  
!     /* Trigger CmdwinLeave autocommands. */
      trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE);
  
  # ifdef FEAT_FOLDING
!     /* Restore KeyTyped in case it is modified by autocommands */
      KeyTyped = save_KeyTyped;
  # endif
  
--- 4181,4191 ----
      save_KeyTyped = KeyTyped;
  # endif
  
!     // Trigger CmdwinLeave autocommands.
      trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE);
  
  # ifdef FEAT_FOLDING
!     // Restore KeyTyped in case it is modified by autocommands
      KeyTyped = save_KeyTyped;
  # endif
  
***************
*** 4268,4277 ****
            }
        }
  
-       /* Don't execute autocommands while deleting the window. */
-       block_autocmds();
  # ifdef FEAT_CONCEAL
!       /* Avoid command-line window first character being concealed. */
        curwin->w_p_cole = 0;
  # endif
        wp = curwin;
--- 4262,4269 ----
            }
        }
  
  # ifdef FEAT_CONCEAL
!       // Avoid command-line window first character being concealed.
        curwin->w_p_cole = 0;
  # endif
        wp = curwin;
***************
*** 4279,4293 ****
        win_goto(old_curwin);
        win_close(wp, TRUE);
  
!       /* win_close() may have already wiped the buffer when 'bh' is
!        * set to 'wipe' */
        if (bufref_valid(&bufref))
            close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE);
  
!       /* Restore window sizes. */
        win_size_restore(&winsizes);
- 
-       unblock_autocmds();
      }
  
      ga_clear(&winsizes);
--- 4271,4283 ----
        win_goto(old_curwin);
        win_close(wp, TRUE);
  
!       // win_close() may have already wiped the buffer when 'bh' is
!       // set to 'wipe'
        if (bufref_valid(&bufref))
            close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE);
  
!       // Restore window sizes.
        win_size_restore(&winsizes);
      }
  
      ga_clear(&winsizes);
***************
*** 4303,4309 ****
  
      return cmdwin_result;
  }
! #endif /* FEAT_CMDWIN */
  
  /*
   * Used for commands that either take a simple command string argument, or:
--- 4293,4299 ----
  
      return cmdwin_result;
  }
! #endif // FEAT_CMDWIN
  
  /*
   * Used for commands that either take a simple command string argument, or:
*** ../vim-8.1.2016/src/testdir/test_cmdline.vim        2019-09-06 
21:34:25.362847408 +0200
--- src/testdir/test_cmdline.vim        2019-09-09 18:27:13.604863314 +0200
***************
*** 604,609 ****
--- 604,611 ----
    return ''
  endfunc
  
+ set cpo&
+ 
  func Test_getcmdtype()
    call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt")
  
***************
*** 644,649 ****
--- 646,682 ----
    call assert_equal('', getcmdwintype())
  endfunc
  
+ func Test_getcmdwin_autocmd()
+   let s:seq = []
+   augroup CmdWin
+   au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid())
+   au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid())
+   au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr())
+   au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr())
+   au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid())
+   au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid())
+ 
+   let org_winid = win_getid()
+   let org_bufnr = bufnr()
+   call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = 
win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!')
+   call assert_equal(':', a)
+   call assert_equal([
+       \ 'WinLeave ' .. org_winid,
+       \ 'WinEnter ' .. s:cmd_winid,
+       \ 'BufLeave ' .. org_bufnr,
+       \ 'BufEnter ' .. s:cmd_bufnr,
+       \ 'CmdWinEnter ' .. s:cmd_winid,
+       \ 'CmdWinLeave ' .. s:cmd_winid,
+       \ 'BufLeave ' .. s:cmd_bufnr,
+       \ 'WinLeave ' .. s:cmd_winid,
+       \ 'WinEnter ' .. org_winid,
+       \ 'BufEnter ' .. org_bufnr,
+       \ ], s:seq)
+ 
+   au!
+   augroup END
+ endfunc
+ 
  func Test_verbosefile()
    set verbosefile=Xlog
    echomsg 'foo'
***************
*** 701,705 ****
  
    let &encoding = encoding_save
  endfunc
- 
- set cpo&
--- 734,736 ----
*** ../vim-8.1.2016/src/version.c       2019-09-08 22:57:11.488090061 +0200
--- src/version.c       2019-09-09 17:57:26.014144704 +0200
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     2017,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
228. You spend Saturday night making the counter on your home page
     pass that 2000 mark.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/201909091636.x89GaCnw013423%40masaka.moolenaar.net.

Raspunde prin e-mail lui