mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
Add TabClosed event
TabClosed is triggered when a tab page closes.
This commit is contained in:

committed by
Justin M. Keyes

parent
66d94869a0
commit
3ffc5d81c3
@@ -5328,10 +5328,12 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
|
||||
int done = 0;
|
||||
win_T *wp;
|
||||
int h = tabline_height();
|
||||
char_u prev_idx[NUMBUFLEN];
|
||||
|
||||
/* Limit to 1000 windows, autocommands may add a window while we close
|
||||
* one. OK, so I'm paranoid... */
|
||||
while (++done < 1000) {
|
||||
sprintf((char *)prev_idx, "%i", tabpage_index(tp));
|
||||
wp = tp->tp_firstwin;
|
||||
ex_win_close(forceit, wp, tp);
|
||||
|
||||
@@ -5340,6 +5342,7 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
|
||||
if (!valid_tabpage(tp) || tp->tp_firstwin == wp)
|
||||
break;
|
||||
}
|
||||
apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, FALSE, curbuf);
|
||||
|
||||
redraw_tabline = TRUE;
|
||||
if (h != tabline_height())
|
||||
|
@@ -5245,6 +5245,7 @@ static struct event_name {
|
||||
{"StdinReadPre", EVENT_STDINREADPRE},
|
||||
{"SwapExists", EVENT_SWAPEXISTS},
|
||||
{"Syntax", EVENT_SYNTAX},
|
||||
{"TabClosed", EVENT_TABCLOSED},
|
||||
{"TabEnter", EVENT_TABENTER},
|
||||
{"TabLeave", EVENT_TABLEAVE},
|
||||
{"TabNew", EVENT_TABNEW},
|
||||
@@ -6634,7 +6635,8 @@ apply_autocmds_group (
|
||||
|| event == EVENT_QUICKFIXCMDPRE
|
||||
|| event == EVENT_COLORSCHEME
|
||||
|| event == EVENT_QUICKFIXCMDPOST
|
||||
|| event == EVENT_JOBACTIVITY)
|
||||
|| event == EVENT_JOBACTIVITY
|
||||
|| event == EVENT_TABCLOSED)
|
||||
fname = vim_strsave(fname);
|
||||
else
|
||||
fname = FullName_save(fname, FALSE);
|
||||
|
@@ -93,6 +93,7 @@ typedef enum auto_event {
|
||||
EVENT_SPELLFILEMISSING, /* spell file missing */
|
||||
EVENT_CURSORMOVED, /* cursor was moved */
|
||||
EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */
|
||||
EVENT_TABCLOSED, /* a tab has closed */
|
||||
EVENT_TABLEAVE, /* before leaving a tab page */
|
||||
EVENT_TABENTER, /* after entering a tab page */
|
||||
EVENT_TABNEW, /* when creating a new tab */
|
||||
|
@@ -1791,6 +1791,9 @@ static int close_last_window_tabpage(win_T *win, int free_buf, tabpage_T *prev_c
|
||||
}
|
||||
/* Since goto_tabpage_tp above did not trigger *Enter autocommands, do
|
||||
* that now. */
|
||||
char_u prev_idx[NUMBUFLEN];
|
||||
sprintf((char *)prev_idx, "%i", tabpage_index(prev_curtab));
|
||||
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)
|
||||
|
Reference in New Issue
Block a user