diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-12-30 14:12:25 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-12-30 14:12:25 +0100 |
commit | 9dc90fcde1e171001bd17f680c866b2461bbc48a (patch) | |
tree | db06198d0313f7995346f364ada37945f4ba86d6 /src/nvim/window.c | |
parent | 3eaa9a2579f5406f80e0d1d67f2e74c5a33c5e18 (diff) | |
parent | 5dd2ca767f3163cb9d051a9a2676ac88f600ebad (diff) | |
download | rneovim-9dc90fcde1e171001bd17f680c866b2461bbc48a.tar.gz rneovim-9dc90fcde1e171001bd17f680c866b2461bbc48a.tar.bz2 rneovim-9dc90fcde1e171001bd17f680c866b2461bbc48a.zip |
Merge #7782 'Fix TabClose autocommand via close_windows'
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 5e85a9bede..2e1507c0ee 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1724,7 +1724,6 @@ void close_windows(buf_T *buf, int keep_curwin) { tabpage_T *tp, *nexttp; int h = tabline_height(); - int count = tabpage_index(NULL); ++RedrawingDisabled; @@ -1762,10 +1761,6 @@ void close_windows(buf_T *buf, int keep_curwin) --RedrawingDisabled; - if (count != tabpage_index(NULL)) { - apply_autocmds(EVENT_TABCLOSED, NULL, NULL, false, curbuf); - } - redraw_tabline = true; if (h != tabline_height()) { shell_new_rows(); @@ -1848,7 +1843,6 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, // Since goto_tabpage_tp above did not trigger *Enter autocommands, do // that now. - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf); if (old_curbuf != curbuf) { @@ -2108,6 +2102,11 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) /* When closing the last window in a tab page remove the tab page. */ if (tp->tp_firstwin == tp->tp_lastwin) { + char_u prev_idx[NUMBUFLEN]; + if (has_event(EVENT_TABCLOSED)) { + vim_snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(tp)); + } + if (tp == first_tabpage) first_tabpage = tp->tp_next; else { @@ -2121,6 +2120,10 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) ptp->tp_next = tp->tp_next; } free_tp = TRUE; + + if (has_event(EVENT_TABCLOSED)) { + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer); + } } /* Free the memory used for the window. */ |