]> granicus.if.org Git - vim/commitdiff
patch 7.4.2077 v7.4.2077
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Jul 2016 21:13:03 +0000 (23:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Jul 2016 21:13:03 +0000 (23:13 +0200)
Problem:    Cannot update 'tabline' when a tab was closed.
Solution:   Add the TabClosed autocmd event. (partly by Felipe Morales)

runtime/doc/autocmd.txt
src/fileio.c
src/testdir/test_autocmd.vim
src/version.c
src/vim.h
src/window.c

index c924af32ddeb1b5d5ecc90fa343b0a0b13cae7d0..e5fc361f1c7a304de19d66e9f0068303e980ee3c 100644 (file)
@@ -1,4 +1,4 @@
-*autocmd.txt*   For Vim version 7.4.  Last change: 2016 Jun 09
+*autocmd.txt*   For Vim version 7.4.  Last change: 2016 Jul 19
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -294,7 +294,8 @@ Name                        triggered by ~
 |CursorMovedI|         the cursor was moved in Insert mode
 
 |WinNew|               after creating a new window
-|TabNew|               after creating a new window
+|TabNew|               after creating a new tab page
+|TabClosed|            after closing a tab page
 |WinEnter|             after entering another window
 |WinLeave|             before leaving a window
 |TabEnter|             after entering another tab page
@@ -311,9 +312,6 @@ Name                        triggered by ~
 |TextChanged|          after a change was made to the text in Normal mode
 |TextChangedI|         after a change was made to the text in Insert mode
 
-|TextChanged|          after a change was made to the text in Normal mode
-|TextChangedI|         after a change was made to the text in Insert mode
-
 |ColorScheme|          after loading a color scheme
 
 |RemoteReply|          a reply from a server Vim was received
@@ -879,6 +877,8 @@ Syntax                              When the 'syntax' option has been set.  The
                                where this option was set, and <amatch> for
                                the new value of 'syntax'.
                                See |:syn-on|.
+                                                       *TabClosed*
+TabClosed                      After closing a tab page.
                                                        *TabEnter*
 TabEnter                       Just after entering a tab page. |tab-page|
                                After triggering the WinEnter and before
@@ -976,6 +976,11 @@ WinLeave                   Before leaving a window.  If the window to be
                                WinLeave autocommands (but not for ":new").
                                Not used for ":qa" or ":q" when exiting Vim.
 
+                                                       *WinNew*
+WinNew                         When a new window was created.  Not done for
+                               the fist window, when Vim has just started.
+                               Before a WinEnter event.
+
 ==============================================================================
 6. Patterns                                    *autocmd-patterns* *{pat}*
 
index 0a84576e576e7f83a1a472ea639c8e2b78ead6ef..ea01b763f0cdb268ab432fbb9b84692bbd0f7a15 100644 (file)
@@ -7707,6 +7707,7 @@ static struct event_name
     {"SwapExists",     EVENT_SWAPEXISTS},
     {"Syntax",         EVENT_SYNTAX},
     {"TabNew",         EVENT_TABNEW},
+    {"TabClosed",      EVENT_TABCLOSED},
     {"TabEnter",       EVENT_TABENTER},
     {"TabLeave",       EVENT_TABLEAVE},
     {"TermChanged",    EVENT_TERMCHANGED},
index 14254a7fad6e0b39858467b57c1463b9fa99a06c..580c42fe4d431d0942d34fed6989667adbe0b669 100644 (file)
@@ -87,6 +87,7 @@ func Test_win_tab_autocmd()
     au WinEnter * call add(g:record, 'WinEnter') 
     au WinLeave * call add(g:record, 'WinLeave') 
     au TabNew * call add(g:record, 'TabNew')
+    au TabClosed * call add(g:record, 'TabClosed')
     au TabEnter * call add(g:record, 'TabEnter')
     au TabLeave * call add(g:record, 'TabLeave')
   augroup END
@@ -99,10 +100,21 @@ func Test_win_tab_autocmd()
   call assert_equal([
        \ 'WinLeave', 'WinNew', 'WinEnter',
        \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter',
-       \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter',
+       \ 'WinLeave', 'TabLeave', 'TabClosed', 'WinEnter', 'TabEnter',
        \ 'WinLeave', 'WinEnter'
        \ ], g:record)
 
+  let g:record = []
+  tabnew somefile
+  tabnext
+  bwipe somefile
+
+  call assert_equal([
+       \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter',
+       \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter',
+       \ 'TabClosed'
+       \ ], g:record)
+
   augroup testing
     au!
   augroup END
index 6f1d53a26185a74af9a90329930cddb2dd26187a..892894af73755b6ab82979f6e3a0efcb9700f932 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2077,
 /**/
     2076,
 /**/
index d9a60dd6b535517dfeef02ead47b9300d4190e2a..488f2708438aead6bb9e63e737d50295778b9287 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -1331,6 +1331,7 @@ enum auto_event
     EVENT_TABENTER,            /* after entering a tab page */
     EVENT_TABLEAVE,            /* before leaving a tab page */
     EVENT_TABNEW,              /* when entering a new tab page */
+    EVENT_TABCLOSED,           /* after closing a tab page */
     EVENT_SHELLCMDPOST,                /* after ":!cmd" */
     EVENT_SHELLFILTERPOST,     /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
     EVENT_TEXTCHANGED,         /* text was modified */
index bf650f84b9b48d6acdde639c741a9f6f763ae828..4fbe6ca58524cd36f9e72861806aea62f3ee9dc1 100644 (file)
@@ -2095,6 +2095,9 @@ close_windows(
     win_T      *wp;
     tabpage_T   *tp, *nexttp;
     int                h = tabline_height();
+#ifdef FEAT_AUTOCMD
+    int                count = tabpage_index(NULL);
+#endif
 
     ++RedrawingDisabled;
 
@@ -2138,6 +2141,11 @@ close_windows(
 
     --RedrawingDisabled;
 
+#ifdef FEAT_AUTOCMD
+    if (count != tabpage_index(NULL))
+       apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
+#endif
+
     redraw_tabline = TRUE;
     if (h != tabline_height())
        shell_new_rows();
@@ -2220,6 +2228,7 @@ close_last_window_tabpage(
        /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do
         * that now. */
 #ifdef FEAT_AUTOCMD
+       apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
        apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
        apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
        if (old_curbuf != curbuf)