patch 9.1.1211: TabClosedPre is triggered just before the tab is being freed

Problem:  TabClosedPre is triggered just before the tab is being freed,
          which limited its functionality.
Solution: Trigger it a bit earlier and also on :tabclose and :tabonly
          (Jim Zhou)

closes: #16890

Signed-off-by: Jim Zhou <jimzhouzzy@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Jim Zhou
2025-03-16 20:24:57 +01:00
committed by Christian Brabandt
parent 21ac3a49b5
commit bcf66e0141
5 changed files with 53 additions and 4 deletions

View File

@ -6536,6 +6536,8 @@ tabpage_close(int forceit)
if (window_layout_locked(CMD_tabclose))
return;
trigger_tabclosedpre(curtab, TRUE);
// First close all the windows but the current one. If that worked then
// close the last window in this tab, that will close it.
if (!ONE_WINDOW)
@ -6559,6 +6561,8 @@ tabpage_close_other(tabpage_T *tp, int forceit)
int done = 0;
win_T *wp;
trigger_tabclosedpre(tp, TRUE);
// Limit to 1000 windows, autocommands may add a window while we close
// one. OK, so I'm paranoid...
while (++done < 1000)