0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.3.551

Problem:    When using :tablose a TabEnter autocommand is triggered too early.
            (Karthick)
Solution:   Don't trigger *Enter autocommands before closing the tab.
            (Christian Brabandt)
This commit is contained in:
Bram Moolenaar 2012-06-13 14:28:20 +02:00
parent e04a48f204
commit a8596c4772
7 changed files with 44 additions and 27 deletions

View File

@ -4470,7 +4470,7 @@ do_arg_all(count, forceit, keep_tabs)
* When the ":tab" modifier was used do this for all tab pages. * When the ":tab" modifier was used do this for all tab pages.
*/ */
if (had_tab > 0) if (had_tab > 0)
goto_tabpage_tp(first_tabpage); goto_tabpage_tp(first_tabpage, TRUE);
for (;;) for (;;)
{ {
tpnext = curtab->tp_next; tpnext = curtab->tp_next;
@ -4582,7 +4582,7 @@ do_arg_all(count, forceit, keep_tabs)
if (!valid_tabpage(tpnext)) if (!valid_tabpage(tpnext))
tpnext = first_tabpage; /* start all over...*/ tpnext = first_tabpage; /* start all over...*/
# endif # endif
goto_tabpage_tp(tpnext); goto_tabpage_tp(tpnext, TRUE);
} }
/* /*
@ -4686,13 +4686,13 @@ do_arg_all(count, forceit, keep_tabs)
if (last_curtab != new_curtab) if (last_curtab != new_curtab)
{ {
if (valid_tabpage(last_curtab)) if (valid_tabpage(last_curtab))
goto_tabpage_tp(last_curtab); goto_tabpage_tp(last_curtab, TRUE);
if (win_valid(last_curwin)) if (win_valid(last_curwin))
win_enter(last_curwin, FALSE); win_enter(last_curwin, FALSE);
} }
/* to window with first arg */ /* to window with first arg */
if (valid_tabpage(new_curtab)) if (valid_tabpage(new_curtab))
goto_tabpage_tp(new_curtab); goto_tabpage_tp(new_curtab, TRUE);
if (win_valid(new_curwin)) if (win_valid(new_curwin))
win_enter(new_curwin, FALSE); win_enter(new_curwin, FALSE);
@ -4744,7 +4744,7 @@ ex_buffer_all(eap)
*/ */
#ifdef FEAT_WINDOWS #ifdef FEAT_WINDOWS
if (had_tab > 0) if (had_tab > 0)
goto_tabpage_tp(first_tabpage); goto_tabpage_tp(first_tabpage, TRUE);
for (;;) for (;;)
{ {
#endif #endif
@ -4784,7 +4784,7 @@ ex_buffer_all(eap)
/* Without the ":tab" modifier only do the current tab page. */ /* Without the ":tab" modifier only do the current tab page. */
if (had_tab == 0 || tpnext == NULL) if (had_tab == 0 || tpnext == NULL)
break; break;
goto_tabpage_tp(tpnext); goto_tabpage_tp(tpnext, TRUE);
} }
#endif #endif

View File

@ -16415,7 +16415,7 @@ f_settabvar(argvars, rettv)
if (tp != NULL && varname != NULL && varp != NULL) if (tp != NULL && varname != NULL && varp != NULL)
{ {
save_curtab = curtab; save_curtab = curtab;
goto_tabpage_tp(tp); goto_tabpage_tp(tp, TRUE);
tabvarname = alloc((unsigned)STRLEN(varname) + 3); tabvarname = alloc((unsigned)STRLEN(varname) + 3);
if (tabvarname != NULL) if (tabvarname != NULL)
@ -16428,7 +16428,7 @@ f_settabvar(argvars, rettv)
/* Restore current tabpage */ /* Restore current tabpage */
if (valid_tabpage(save_curtab)) if (valid_tabpage(save_curtab))
goto_tabpage_tp(save_curtab); goto_tabpage_tp(save_curtab, TRUE);
} }
} }
@ -16492,7 +16492,7 @@ setwinvar(argvars, rettv, off)
/* set curwin to be our win, temporarily */ /* set curwin to be our win, temporarily */
save_curwin = curwin; save_curwin = curwin;
save_curtab = curtab; save_curtab = curtab;
goto_tabpage_tp(tp); goto_tabpage_tp(tp, TRUE);
if (!win_valid(win)) if (!win_valid(win))
return; return;
curwin = win; curwin = win;
@ -16527,7 +16527,7 @@ setwinvar(argvars, rettv, off)
/* Restore current tabpage and window, if still valid (autocomands can /* Restore current tabpage and window, if still valid (autocomands can
* make them invalid). */ * make them invalid). */
if (valid_tabpage(save_curtab)) if (valid_tabpage(save_curtab))
goto_tabpage_tp(save_curtab); goto_tabpage_tp(save_curtab, TRUE);
if (win_valid(save_curwin)) if (win_valid(save_curwin))
{ {
curwin = save_curwin; curwin = save_curwin;

View File

@ -2476,7 +2476,7 @@ ex_listdo(eap)
/* go to window "tp" */ /* go to window "tp" */
if (!valid_tabpage(tp)) if (!valid_tabpage(tp))
break; break;
goto_tabpage_tp(tp); goto_tabpage_tp(tp, TRUE);
tp = tp->tp_next; tp = tp->tp_next;
} }
#endif #endif

View File

@ -8918,7 +8918,7 @@ aucmd_restbuf(aco)
if (wp == aucmd_win) if (wp == aucmd_win)
{ {
if (tp != curtab) if (tp != curtab)
goto_tabpage_tp(tp); goto_tabpage_tp(tp, TRUE);
win_goto(aucmd_win); win_goto(aucmd_win);
goto win_found; goto win_found;
} }

View File

@ -27,7 +27,7 @@ int valid_tabpage __ARGS((tabpage_T *tpc));
tabpage_T *find_tabpage __ARGS((int n)); tabpage_T *find_tabpage __ARGS((int n));
int tabpage_index __ARGS((tabpage_T *ftp)); int tabpage_index __ARGS((tabpage_T *ftp));
void goto_tabpage __ARGS((int n)); void goto_tabpage __ARGS((int n));
void goto_tabpage_tp __ARGS((tabpage_T *tp)); void goto_tabpage_tp __ARGS((tabpage_T *tp, int trigger_autocmds));
void goto_tabpage_win __ARGS((tabpage_T *tp, win_T *wp)); void goto_tabpage_win __ARGS((tabpage_T *tp, win_T *wp));
void tabpage_move __ARGS((int nr)); void tabpage_move __ARGS((int nr));
void win_goto __ARGS((win_T *wp)); void win_goto __ARGS((win_T *wp));

View File

@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
551,
/**/ /**/
550, 550,
/**/ /**/

View File

@ -45,7 +45,7 @@ static void new_frame __ARGS((win_T *wp));
#if defined(FEAT_WINDOWS) || defined(PROTO) #if defined(FEAT_WINDOWS) || defined(PROTO)
static tabpage_T *alloc_tabpage __ARGS((void)); static tabpage_T *alloc_tabpage __ARGS((void));
static int leave_tabpage __ARGS((buf_T *new_curbuf)); static int leave_tabpage __ARGS((buf_T *new_curbuf));
static void enter_tabpage __ARGS((tabpage_T *tp, buf_T *old_curbuf)); static void enter_tabpage __ARGS((tabpage_T *tp, buf_T *old_curbuf, int trigger_autocmds));
static void frame_fix_height __ARGS((win_T *wp)); static void frame_fix_height __ARGS((win_T *wp));
static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin)); static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin));
static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin)); static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin));
@ -355,11 +355,11 @@ newwindow:
&& valid_tabpage(oldtab)) && valid_tabpage(oldtab))
{ {
newtab = curtab; newtab = curtab;
goto_tabpage_tp(oldtab); goto_tabpage_tp(oldtab, TRUE);
if (curwin == wp) if (curwin == wp)
win_close(curwin, FALSE); win_close(curwin, FALSE);
if (valid_tabpage(newtab)) if (valid_tabpage(newtab))
goto_tabpage_tp(newtab); goto_tabpage_tp(newtab, TRUE);
} }
} }
break; break;
@ -2130,8 +2130,10 @@ close_last_window_tabpage(win, free_buf, prev_curtab)
* page and then close the window and the tab page. This avoids that * page and then close the window and the tab page. This avoids that
* curwin and curtab are invalid while we are freeing memory, they may * curwin and curtab are invalid while we are freeing memory, they may
* be used in GUI events. * be used in GUI events.
* Don't trigger autocommands yet, they may use wrong values, so do
* that below.
*/ */
goto_tabpage_tp(alt_tabpage()); goto_tabpage_tp(alt_tabpage(), FALSE);
redraw_tabline = TRUE; redraw_tabline = TRUE;
/* Safety check: Autocommands may have closed the window when jumping /* Safety check: Autocommands may have closed the window when jumping
@ -2144,6 +2146,12 @@ close_last_window_tabpage(win, free_buf, prev_curtab)
if (h != tabline_height()) if (h != tabline_height())
shell_new_rows(); shell_new_rows();
} }
/* Since goto_tabpage_tp above did not trigger *Enter autocommands, do
* that now. */
#ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
#endif
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -3556,7 +3564,7 @@ win_new_tabpage(after)
} }
/* Failed, get back the previous Tab page */ /* Failed, get back the previous Tab page */
enter_tabpage(curtab, curbuf); enter_tabpage(curtab, curbuf, TRUE);
return FAIL; return FAIL;
} }
@ -3709,11 +3717,13 @@ leave_tabpage(new_curbuf)
/* /*
* Start using tab page "tp". * Start using tab page "tp".
* Only to be used after leave_tabpage() or freeing the current tab page. * Only to be used after leave_tabpage() or freeing the current tab page.
* Only trigger *Enter autocommands when trigger_autocmds is TRUE.
*/ */
static void static void
enter_tabpage(tp, old_curbuf) enter_tabpage(tp, old_curbuf, trigger_autocmds)
tabpage_T *tp; tabpage_T *tp;
buf_T *old_curbuf UNUSED; buf_T *old_curbuf UNUSED;
int trigger_autocmds;
{ {
int old_off = tp->tp_firstwin->w_winrow; int old_off = tp->tp_firstwin->w_winrow;
win_T *next_prevwin = tp->tp_prevwin; win_T *next_prevwin = tp->tp_prevwin;
@ -3761,9 +3771,12 @@ enter_tabpage(tp, old_curbuf)
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
/* Apply autocommands after updating the display, when 'rows' and /* Apply autocommands after updating the display, when 'rows' and
* 'columns' have been set correctly. */ * 'columns' have been set correctly. */
apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); if (trigger_autocmds)
if (old_curbuf != curbuf) {
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
if (old_curbuf != curbuf)
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
}
#endif #endif
redraw_all_later(CLEAR); redraw_all_later(CLEAR);
@ -3839,7 +3852,7 @@ goto_tabpage(n)
} }
} }
goto_tabpage_tp(tp); goto_tabpage_tp(tp, TRUE);
#ifdef FEAT_GUI_TABLINE #ifdef FEAT_GUI_TABLINE
if (gui_use_tabline()) if (gui_use_tabline())
@ -3849,11 +3862,13 @@ goto_tabpage(n)
/* /*
* Go to tabpage "tp". * Go to tabpage "tp".
* Only trigger *Enter autocommands when trigger_autocmds is TRUE.
* Note: doesn't update the GUI tab. * Note: doesn't update the GUI tab.
*/ */
void void
goto_tabpage_tp(tp) goto_tabpage_tp(tp, trigger_autocmds)
tabpage_T *tp; tabpage_T *tp;
int trigger_autocmds;
{ {
/* Don't repeat a message in another tab page. */ /* Don't repeat a message in another tab page. */
set_keep_msg(NULL, 0); set_keep_msg(NULL, 0);
@ -3861,9 +3876,9 @@ goto_tabpage_tp(tp)
if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer) == OK) if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer) == OK)
{ {
if (valid_tabpage(tp)) if (valid_tabpage(tp))
enter_tabpage(tp, curbuf); enter_tabpage(tp, curbuf, trigger_autocmds);
else else
enter_tabpage(curtab, curbuf); enter_tabpage(curtab, curbuf, trigger_autocmds);
} }
} }
@ -3876,7 +3891,7 @@ goto_tabpage_win(tp, wp)
tabpage_T *tp; tabpage_T *tp;
win_T *wp; win_T *wp;
{ {
goto_tabpage_tp(tp); goto_tabpage_tp(tp, TRUE);
if (curtab == tp && win_valid(wp)) if (curtab == tp && win_valid(wp))
{ {
win_enter(wp, TRUE); win_enter(wp, TRUE);