• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision5a0d5f8e177838e265bbd0d0c81fff510ba2ea66 (tree)
Time2019-09-10 01:45:04
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.1.2017: cannot execute commands after closing the cmdline window

Commit: https://github.com/vim/vim/commit/96e38a86a710fb6daec4550ac1667f019dc3a40e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 9 18:35:33 2019 +0200

patch 8.1.2017: cannot execute commands after closing the cmdline window
Problem: Cannot execute commands after closing the cmdline window.
Solution: Also trigger BufEnter and WinEnter. (closes https://github.com/vim/vim/issues/4762)

Change Summary

Incremental Difference

diff -r 1616f2fc1e3c -r 5a0d5f8e1778 runtime/doc/autocmd.txt
--- a/runtime/doc/autocmd.txt Sun Sep 08 23:00:04 2019 +0200
+++ b/runtime/doc/autocmd.txt Mon Sep 09 18:45:04 2019 +0200
@@ -554,16 +554,14 @@
554554 *CmdwinEnter*
555555 CmdwinEnter After entering the command-line window.
556556 Useful for setting options specifically for
557- this special type of window. This is
558- triggered _instead_ of BufEnter and WinEnter.
557+ this special type of window.
559558 <afile> is set to a single character,
560559 indicating the type of command-line.
561560 |cmdwin-char|
562561 *CmdwinLeave*
563562 CmdwinLeave Before leaving the command-line window.
564563 Useful to clean up any global setting done
565- with CmdwinEnter. This is triggered _instead_
566- of BufLeave and WinLeave.
564+ with CmdwinEnter.
567565 <afile> is set to a single character,
568566 indicating the type of command-line.
569567 |cmdwin-char|
diff -r 1616f2fc1e3c -r 5a0d5f8e1778 runtime/doc/cmdline.txt
--- a/runtime/doc/cmdline.txt Sun Sep 08 23:00:04 2019 +0200
+++ b/runtime/doc/cmdline.txt Mon Sep 09 18:45:04 2019 +0200
@@ -1171,11 +1171,9 @@
11711171
11721172 AUTOCOMMANDS
11731173
1174-Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|. Since this
1175-window is of a special type, the WinEnter, WinLeave, BufEnter and BufLeave
1176-events are not triggered. You can use the Cmdwin events to do settings
1177-specifically for the command-line window. Be careful not to cause side
1178-effects!
1174+Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|. You can use
1175+the Cmdwin events to do settings specifically for the command-line window.
1176+Be careful not to cause side effects!
11791177 Example: >
11801178 :au CmdwinEnter : let b:cpt_save = &cpt | set cpt=.
11811179 :au CmdwinLeave : let &cpt = b:cpt_save
diff -r 1616f2fc1e3c -r 5a0d5f8e1778 src/ex_getln.c
--- a/src/ex_getln.c Sun Sep 08 23:00:04 2019 +0200
+++ b/src/ex_getln.c Mon Sep 09 18:45:04 2019 +0200
@@ -4069,30 +4069,26 @@
40694069 }
40704070 set_bufref(&old_curbuf, curbuf);
40714071
4072- /* Save current window sizes. */
4072+ // Save current window sizes.
40734073 win_size_save(&winsizes);
40744074
4075- /* Don't execute autocommands while creating the window. */
4076- block_autocmds();
4077-
40784075 // When using completion in Insert mode with <C-R>=<C-F> one can open the
40794076 // command line window, but we don't want the popup menu then.
40804077 pum_undisplay();
40814078
4082- /* don't use a new tab page */
4079+ // don't use a new tab page
40834080 cmdmod.tab = 0;
40844081 cmdmod.noswapfile = 1;
40854082
4086- /* Create a window for the command-line buffer. */
4083+ // Create a window for the command-line buffer.
40874084 if (win_split((int)p_cwh, WSP_BOT) == FAIL)
40884085 {
40894086 beep_flush();
4090- unblock_autocmds();
40914087 return K_IGNORE;
40924088 }
40934089 cmdwin_type = get_cmdline_type();
40944090
4095- /* Create the command-line buffer empty. */
4091+ // Create the command-line buffer empty.
40964092 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
40974093 (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
40984094 set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
@@ -4106,12 +4102,10 @@
41064102 # endif
41074103 RESET_BINDING(curwin);
41084104
4109- /* Do execute autocommands for setting the filetype (load syntax). */
4110- unblock_autocmds();
4111- /* But don't allow switching to another buffer. */
4105+ // Don't allow switching to another buffer.
41124106 ++curbuf_lock;
41134107
4114- /* Showing the prompt may have set need_wait_return, reset it. */
4108+ // Showing the prompt may have set need_wait_return, reset it.
41154109 need_wait_return = FALSE;
41164110
41174111 histtype = hist_char2type(cmdwin_type);
@@ -4126,11 +4120,11 @@
41264120 }
41274121 --curbuf_lock;
41284122
4129- /* Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin
4130- * sets 'textwidth' to 78). */
4123+ // Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin
4124+ // sets 'textwidth' to 78).
41314125 curbuf->b_p_tw = 0;
41324126
4133- /* Fill the buffer with the history. */
4127+ // Fill the buffer with the history.
41344128 init_history();
41354129 if (get_hislen() > 0)
41364130 {
@@ -4167,9 +4161,9 @@
41674161 setmouse();
41684162 # endif
41694163
4170- /* Trigger CmdwinEnter autocommands. */
4164+ // Trigger CmdwinEnter autocommands.
41714165 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER);
4172- if (restart_edit != 0) /* autocmd with ":startinsert" */
4166+ if (restart_edit != 0) // autocmd with ":startinsert"
41734167 stuffcharReadbuff(K_NOP);
41744168
41754169 i = RedrawingDisabled;
@@ -4187,11 +4181,11 @@
41874181 save_KeyTyped = KeyTyped;
41884182 # endif
41894183
4190- /* Trigger CmdwinLeave autocommands. */
4184+ // Trigger CmdwinLeave autocommands.
41914185 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE);
41924186
41934187 # ifdef FEAT_FOLDING
4194- /* Restore KeyTyped in case it is modified by autocommands */
4188+ // Restore KeyTyped in case it is modified by autocommands
41954189 KeyTyped = save_KeyTyped;
41964190 # endif
41974191
@@ -4268,10 +4262,8 @@
42684262 }
42694263 }
42704264
4271- /* Don't execute autocommands while deleting the window. */
4272- block_autocmds();
42734265 # ifdef FEAT_CONCEAL
4274- /* Avoid command-line window first character being concealed. */
4266+ // Avoid command-line window first character being concealed.
42754267 curwin->w_p_cole = 0;
42764268 # endif
42774269 wp = curwin;
@@ -4279,15 +4271,13 @@
42794271 win_goto(old_curwin);
42804272 win_close(wp, TRUE);
42814273
4282- /* win_close() may have already wiped the buffer when 'bh' is
4283- * set to 'wipe' */
4274+ // win_close() may have already wiped the buffer when 'bh' is
4275+ // set to 'wipe'
42844276 if (bufref_valid(&bufref))
42854277 close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE);
42864278
4287- /* Restore window sizes. */
4279+ // Restore window sizes.
42884280 win_size_restore(&winsizes);
4289-
4290- unblock_autocmds();
42914281 }
42924282
42934283 ga_clear(&winsizes);
@@ -4303,7 +4293,7 @@
43034293
43044294 return cmdwin_result;
43054295 }
4306-#endif /* FEAT_CMDWIN */
4296+#endif // FEAT_CMDWIN
43074297
43084298 /*
43094299 * Used for commands that either take a simple command string argument, or:
diff -r 1616f2fc1e3c -r 5a0d5f8e1778 src/testdir/test_cmdline.vim
--- a/src/testdir/test_cmdline.vim Sun Sep 08 23:00:04 2019 +0200
+++ b/src/testdir/test_cmdline.vim Mon Sep 09 18:45:04 2019 +0200
@@ -604,6 +604,8 @@
604604 return ''
605605 endfunc
606606
607+set cpo&
608+
607609 func Test_getcmdtype()
608610 call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt")
609611
@@ -644,6 +646,37 @@
644646 call assert_equal('', getcmdwintype())
645647 endfunc
646648
649+func Test_getcmdwin_autocmd()
650+ let s:seq = []
651+ augroup CmdWin
652+ au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid())
653+ au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid())
654+ au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr())
655+ au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr())
656+ au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid())
657+ au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid())
658+
659+ let org_winid = win_getid()
660+ let org_bufnr = bufnr()
661+ call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!')
662+ call assert_equal(':', a)
663+ call assert_equal([
664+ \ 'WinLeave ' .. org_winid,
665+ \ 'WinEnter ' .. s:cmd_winid,
666+ \ 'BufLeave ' .. org_bufnr,
667+ \ 'BufEnter ' .. s:cmd_bufnr,
668+ \ 'CmdWinEnter ' .. s:cmd_winid,
669+ \ 'CmdWinLeave ' .. s:cmd_winid,
670+ \ 'BufLeave ' .. s:cmd_bufnr,
671+ \ 'WinLeave ' .. s:cmd_winid,
672+ \ 'WinEnter ' .. org_winid,
673+ \ 'BufEnter ' .. org_bufnr,
674+ \ ], s:seq)
675+
676+ au!
677+ augroup END
678+endfunc
679+
647680 func Test_verbosefile()
648681 set verbosefile=Xlog
649682 echomsg 'foo'
@@ -701,5 +734,3 @@
701734
702735 let &encoding = encoding_save
703736 endfunc
704-
705-set cpo&
diff -r 1616f2fc1e3c -r 5a0d5f8e1778 src/version.c
--- a/src/version.c Sun Sep 08 23:00:04 2019 +0200
+++ b/src/version.c Mon Sep 09 18:45:04 2019 +0200
@@ -758,6 +758,8 @@
758758 static int included_patches[] =
759759 { /* Add new patch number below this line */
760760 /**/
761+ 2017,
762+/**/
761763 2016,
762764 /**/
763765 2015,
Show on old repository browser