mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 00:38:17 +00:00
Trigger TabNew before TabEnter
This commit is contained in:
@@ -6290,10 +6290,8 @@ void ex_splitview(exarg_T *eap)
|
|||||||
if (eap->cmdidx == CMD_tabedit
|
if (eap->cmdidx == CMD_tabedit
|
||||||
|| eap->cmdidx == CMD_tabfind
|
|| eap->cmdidx == CMD_tabfind
|
||||||
|| eap->cmdidx == CMD_tabnew) {
|
|| eap->cmdidx == CMD_tabnew) {
|
||||||
if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab
|
if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab : eap->addr_count == 0
|
||||||
: eap->addr_count == 0 ? 0
|
? 0 : (int)eap->line2 + 1, eap->arg) != FAIL) {
|
||||||
: (int)eap->line2 + 1) != FAIL) {
|
|
||||||
apply_autocmds(EVENT_TABNEW, eap->arg, eap->arg, FALSE, curbuf);
|
|
||||||
do_exedit(eap, old_curwin);
|
do_exedit(eap, old_curwin);
|
||||||
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, FALSE, curbuf);
|
||||||
|
|
||||||
|
@@ -248,7 +248,7 @@ newwindow:
|
|||||||
/* First create a new tab with the window, then go back to
|
/* First create a new tab with the window, then go back to
|
||||||
* the old tab and close the window there. */
|
* the old tab and close the window there. */
|
||||||
wp = curwin;
|
wp = curwin;
|
||||||
if (win_new_tabpage((int)Prenum) == OK
|
if (win_new_tabpage((int)Prenum, NULL) == OK
|
||||||
&& valid_tabpage(oldtab)) {
|
&& valid_tabpage(oldtab)) {
|
||||||
newtab = curtab;
|
newtab = curtab;
|
||||||
goto_tabpage_tp(oldtab, TRUE, TRUE);
|
goto_tabpage_tp(oldtab, TRUE, TRUE);
|
||||||
@@ -2952,14 +2952,15 @@ void free_tabpage(tabpage_T *tp)
|
|||||||
xfree(tp);
|
xfree(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Create a new tabpage with one window.
|
||||||
* Create a new Tab page with one window.
|
///
|
||||||
* It will edit the current buffer, like after ":split".
|
/// It will edit the current buffer, like after :split.
|
||||||
* When "after" is 0 put it just after the current Tab page.
|
///
|
||||||
* Otherwise put it just before tab page "after".
|
/// @param after Put new tabpage after tabpage "after", or after the current
|
||||||
* Return FAIL or OK.
|
/// tabpage in case of 0.
|
||||||
*/
|
/// @param filename Will be passed to apply_autocmds().
|
||||||
int win_new_tabpage(int after)
|
/// @return Was the new tabpage created successfully? FAIL or OK.
|
||||||
|
int win_new_tabpage(int after, char_u *filename)
|
||||||
{
|
{
|
||||||
tabpage_T *tp = curtab;
|
tabpage_T *tp = curtab;
|
||||||
tabpage_T *newtp;
|
tabpage_T *newtp;
|
||||||
@@ -2999,10 +3000,12 @@ int win_new_tabpage(int after)
|
|||||||
newtp->tp_topframe = topframe;
|
newtp->tp_topframe = topframe;
|
||||||
last_status(FALSE);
|
last_status(FALSE);
|
||||||
|
|
||||||
|
|
||||||
redraw_all_later(CLEAR);
|
redraw_all_later(CLEAR);
|
||||||
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
|
|
||||||
apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_TABNEW, filename, filename, false, curbuf);
|
||||||
|
apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf);
|
||||||
|
apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3023,7 +3026,7 @@ int may_open_tabpage(void)
|
|||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
cmdmod.tab = 0; /* reset it to avoid doing it twice */
|
cmdmod.tab = 0; /* reset it to avoid doing it twice */
|
||||||
postponed_split_tab = 0;
|
postponed_split_tab = 0;
|
||||||
return win_new_tabpage(n);
|
return win_new_tabpage(n, NULL);
|
||||||
}
|
}
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@@ -3047,9 +3050,11 @@ int make_tabpages(int maxcount)
|
|||||||
*/
|
*/
|
||||||
block_autocmds();
|
block_autocmds();
|
||||||
|
|
||||||
for (todo = count - 1; todo > 0; --todo)
|
for (todo = count - 1; todo > 0; --todo) {
|
||||||
if (win_new_tabpage(0) == FAIL)
|
if (win_new_tabpage(0, NULL) == FAIL) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unblock_autocmds();
|
unblock_autocmds();
|
||||||
|
|
||||||
|
@@ -139,6 +139,7 @@ describe('tab pages', function()
|
|||||||
autocmd TabLeave * :call add(g:r, 'TabLeave')
|
autocmd TabLeave * :call add(g:r, 'TabLeave')
|
||||||
autocmd WinLeave * :call add(g:r, 'WinLeave')
|
autocmd WinLeave * :call add(g:r, 'WinLeave')
|
||||||
autocmd BufLeave * :call add(g:r, 'BufLeave')
|
autocmd BufLeave * :call add(g:r, 'BufLeave')
|
||||||
|
autocmd TabNew * :call add(g:r, 'TabNew')
|
||||||
let t:a='a'
|
let t:a='a'
|
||||||
C tab split
|
C tab split
|
||||||
let t:a='b'
|
let t:a='b'
|
||||||
@@ -185,11 +186,13 @@ describe('tab pages', function()
|
|||||||
=== tab split ===
|
=== tab split ===
|
||||||
WinLeave
|
WinLeave
|
||||||
TabLeave
|
TabLeave
|
||||||
|
TabNew
|
||||||
WinEnter
|
WinEnter
|
||||||
TabEnter
|
TabEnter
|
||||||
=== tabnew ===
|
=== tabnew ===
|
||||||
WinLeave
|
WinLeave
|
||||||
TabLeave
|
TabLeave
|
||||||
|
TabNew
|
||||||
WinEnter
|
WinEnter
|
||||||
TabEnter
|
TabEnter
|
||||||
BufLeave
|
BufLeave
|
||||||
@@ -222,6 +225,7 @@ describe('tab pages', function()
|
|||||||
=== tabnew ===
|
=== tabnew ===
|
||||||
WinLeave
|
WinLeave
|
||||||
TabLeave
|
TabLeave
|
||||||
|
TabNew
|
||||||
WinEnter
|
WinEnter
|
||||||
TabEnter
|
TabEnter
|
||||||
BufLeave
|
BufLeave
|
||||||
|
Reference in New Issue
Block a user