• R/O
  • SSH

vim: Commit

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


Commit MetaInfo

Revision0b337617877ecc351396d1afc62e4bb093a3115b (tree)
Time2020-01-14 05:00:03
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"

Commit: https://github.com/vim/vim/commit/c10b521628f2b073fa231defa26f23937c91724d
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 13 20:54:51 2020 +0100

patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Problem: BufEnter autocmd not triggered on ":tab drop". (Andy Stewart)
Solution: Decrement autocmd_no_enter for the last file. (closes https://github.com/vim/vim/issues/1660,
closes #5473)

Change Summary

Incremental Difference

diff -r ca362df0be20 -r 0b337617877e src/arglist.c
--- a/src/arglist.c Mon Jan 13 20:45:04 2020 +0100
+++ b/src/arglist.c Mon Jan 13 21:00:03 2020 +0100
@@ -864,6 +864,7 @@
864864 //
865865 int opened_len; // length of opened[]
866866 int use_firstwin = FALSE; // use first window for arglist
867+ int tab_drop_empty_window = FALSE;
867868 int split_ret = OK;
868869 int p_ea_save;
869870 alist_T *alist; // argument list to be used
@@ -1027,13 +1028,16 @@
10271028 last_curwin = curwin;
10281029 last_curtab = curtab;
10291030 win_enter(lastwin, FALSE);
1030- // ":drop all" should re-use an empty window to avoid "--remote-tab"
1031+ // ":tab drop file" should re-use an empty window to avoid "--remote-tab"
10311032 // leaving an empty tab page when executed locally.
10321033 if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1
10331034 && curbuf->b_ffname == NULL && !curbuf->b_changed)
1035+ {
10341036 use_firstwin = TRUE;
1037+ tab_drop_empty_window = TRUE;
1038+ }
10351039
1036- for (i = 0; i < count && i < opened_len && !got_int; ++i)
1040+ for (i = 0; i < count && !got_int; ++i)
10371041 {
10381042 if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1)
10391043 arg_had_last = TRUE;
@@ -1067,6 +1071,9 @@
10671071 }
10681072 else if (split_ret == OK)
10691073 {
1074+ // trigger events for tab drop
1075+ if (tab_drop_empty_window && i == count - 1)
1076+ --autocmd_no_enter;
10701077 if (!use_firstwin) // split current window
10711078 {
10721079 p_ea_save = p_ea;
@@ -1091,6 +1098,8 @@
10911098 ((buf_hide(curwin->w_buffer)
10921099 || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
10931100 + ECMD_OLDBUF, curwin);
1101+ if (tab_drop_empty_window && i == count - 1)
1102+ ++autocmd_no_enter;
10941103 if (use_firstwin)
10951104 ++autocmd_no_leave;
10961105 use_firstwin = FALSE;
diff -r ca362df0be20 -r 0b337617877e src/testdir/test_tabpage.vim
--- a/src/testdir/test_tabpage.vim Mon Jan 13 20:45:04 2020 +0100
+++ b/src/testdir/test_tabpage.vim Mon Jan 13 21:00:03 2020 +0100
@@ -222,6 +222,34 @@
222222 1tabonly!
223223 endfunction
224224
225+" Test autocommands on tab drop
226+function Test_tabpage_with_autocmd_tab_drop()
227+ augroup TestTabpageGroup
228+ au!
229+ autocmd TabEnter * call add(s:li, 'TabEnter')
230+ autocmd WinEnter * call add(s:li, 'WinEnter')
231+ autocmd BufEnter * call add(s:li, 'BufEnter')
232+ autocmd TabLeave * call add(s:li, 'TabLeave')
233+ autocmd WinLeave * call add(s:li, 'WinLeave')
234+ autocmd BufLeave * call add(s:li, 'BufLeave')
235+ augroup END
236+
237+ let s:li = []
238+ tab drop test1
239+ call assert_equal(['BufLeave', 'BufEnter'], s:li)
240+
241+ let s:li = []
242+ tab drop test2 test3
243+ call assert_equal([
244+ \ 'TabLeave', 'TabEnter', 'TabLeave', 'TabEnter',
245+ \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter',
246+ \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li)
247+
248+ autocmd! TestTabpageGroup
249+ augroup! TestTabpageGroup
250+ 1tabonly!
251+endfunction
252+
225253 function Test_tabpage_with_tab_modifier()
226254 CheckFeature quickfix
227255
diff -r ca362df0be20 -r 0b337617877e src/version.c
--- a/src/version.c Mon Jan 13 20:45:04 2020 +0100
+++ b/src/version.c Mon Jan 13 21:00:03 2020 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 116,
747+/**/
746748 115,
747749 /**/
748750 114,
Show on old repository browser