diff options
author | Bram Moolenaar <Bram@vim.org> | 2012-06-13 14:28:20 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2012-06-13 14:28:20 +0200 |
commit | a8596c47724b97822924f5ffe5d50476de31ff4b (patch) | |
tree | 77bfb95357a498955a7e8b2c8662b5a1b5b76c0d | |
parent | e04a48f20413f3f926d26394fad6431795348af7 (diff) | |
download | vim-git-a8596c47724b97822924f5ffe5d50476de31ff4b.tar.gz |
updated for version 7.3.551v7.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)
-rw-r--r-- | src/buffer.c | 12 | ||||
-rw-r--r-- | src/eval.c | 8 | ||||
-rw-r--r-- | src/ex_cmds2.c | 2 | ||||
-rw-r--r-- | src/fileio.c | 2 | ||||
-rw-r--r-- | src/proto/window.pro | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 43 |
7 files changed, 44 insertions, 27 deletions
diff --git a/src/buffer.c b/src/buffer.c index 00d1f3535..e27626eb1 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4470,7 +4470,7 @@ do_arg_all(count, forceit, keep_tabs) * When the ":tab" modifier was used do this for all tab pages. */ if (had_tab > 0) - goto_tabpage_tp(first_tabpage); + goto_tabpage_tp(first_tabpage, TRUE); for (;;) { tpnext = curtab->tp_next; @@ -4582,7 +4582,7 @@ do_arg_all(count, forceit, keep_tabs) if (!valid_tabpage(tpnext)) tpnext = first_tabpage; /* start all over...*/ # 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 (valid_tabpage(last_curtab)) - goto_tabpage_tp(last_curtab); + goto_tabpage_tp(last_curtab, TRUE); if (win_valid(last_curwin)) win_enter(last_curwin, FALSE); } /* to window with first arg */ if (valid_tabpage(new_curtab)) - goto_tabpage_tp(new_curtab); + goto_tabpage_tp(new_curtab, TRUE); if (win_valid(new_curwin)) win_enter(new_curwin, FALSE); @@ -4744,7 +4744,7 @@ ex_buffer_all(eap) */ #ifdef FEAT_WINDOWS if (had_tab > 0) - goto_tabpage_tp(first_tabpage); + goto_tabpage_tp(first_tabpage, TRUE); for (;;) { #endif @@ -4784,7 +4784,7 @@ ex_buffer_all(eap) /* Without the ":tab" modifier only do the current tab page. */ if (had_tab == 0 || tpnext == NULL) break; - goto_tabpage_tp(tpnext); + goto_tabpage_tp(tpnext, TRUE); } #endif diff --git a/src/eval.c b/src/eval.c index b0e4b31fa..d238dc2ba 100644 --- a/src/eval.c +++ b/src/eval.c @@ -16415,7 +16415,7 @@ f_settabvar(argvars, rettv) if (tp != NULL && varname != NULL && varp != NULL) { save_curtab = curtab; - goto_tabpage_tp(tp); + goto_tabpage_tp(tp, TRUE); tabvarname = alloc((unsigned)STRLEN(varname) + 3); if (tabvarname != NULL) @@ -16428,7 +16428,7 @@ f_settabvar(argvars, rettv) /* Restore current tabpage */ 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 */ save_curwin = curwin; save_curtab = curtab; - goto_tabpage_tp(tp); + goto_tabpage_tp(tp, TRUE); if (!win_valid(win)) return; curwin = win; @@ -16527,7 +16527,7 @@ setwinvar(argvars, rettv, off) /* Restore current tabpage and window, if still valid (autocomands can * make them invalid). */ if (valid_tabpage(save_curtab)) - goto_tabpage_tp(save_curtab); + goto_tabpage_tp(save_curtab, TRUE); if (win_valid(save_curwin)) { curwin = save_curwin; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 611a36339..6b12c4245 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2476,7 +2476,7 @@ ex_listdo(eap) /* go to window "tp" */ if (!valid_tabpage(tp)) break; - goto_tabpage_tp(tp); + goto_tabpage_tp(tp, TRUE); tp = tp->tp_next; } #endif diff --git a/src/fileio.c b/src/fileio.c index 078142468..d88ff25f6 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -8918,7 +8918,7 @@ aucmd_restbuf(aco) if (wp == aucmd_win) { if (tp != curtab) - goto_tabpage_tp(tp); + goto_tabpage_tp(tp, TRUE); win_goto(aucmd_win); goto win_found; } diff --git a/src/proto/window.pro b/src/proto/window.pro index d56ae1b33..847b64bb5 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -27,7 +27,7 @@ int valid_tabpage __ARGS((tabpage_T *tpc)); tabpage_T *find_tabpage __ARGS((int n)); int tabpage_index __ARGS((tabpage_T *ftp)); 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 tabpage_move __ARGS((int nr)); void win_goto __ARGS((win_T *wp)); diff --git a/src/version.c b/src/version.c index e3abb957c..5e08bac52 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 551, +/**/ 550, /**/ 549, diff --git a/src/window.c b/src/window.c index ecf2aa29a..f036c37cd 100644 --- a/src/window.c +++ b/src/window.c @@ -45,7 +45,7 @@ static void new_frame __ARGS((win_T *wp)); #if defined(FEAT_WINDOWS) || defined(PROTO) static tabpage_T *alloc_tabpage __ARGS((void)); 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 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)); @@ -355,11 +355,11 @@ newwindow: && valid_tabpage(oldtab)) { newtab = curtab; - goto_tabpage_tp(oldtab); + goto_tabpage_tp(oldtab, TRUE); if (curwin == wp) win_close(curwin, FALSE); if (valid_tabpage(newtab)) - goto_tabpage_tp(newtab); + goto_tabpage_tp(newtab, TRUE); } } 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 * curwin and curtab are invalid while we are freeing memory, they may * 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; /* 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()) 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 FALSE; @@ -3556,7 +3564,7 @@ win_new_tabpage(after) } /* Failed, get back the previous Tab page */ - enter_tabpage(curtab, curbuf); + enter_tabpage(curtab, curbuf, TRUE); return FAIL; } @@ -3709,11 +3717,13 @@ leave_tabpage(new_curbuf) /* * Start using tab page "tp". * Only to be used after leave_tabpage() or freeing the current tab page. + * Only trigger *Enter autocommands when trigger_autocmds is TRUE. */ static void -enter_tabpage(tp, old_curbuf) +enter_tabpage(tp, old_curbuf, trigger_autocmds) tabpage_T *tp; buf_T *old_curbuf UNUSED; + int trigger_autocmds; { int old_off = tp->tp_firstwin->w_winrow; win_T *next_prevwin = tp->tp_prevwin; @@ -3761,9 +3771,12 @@ enter_tabpage(tp, old_curbuf) #ifdef FEAT_AUTOCMD /* Apply autocommands after updating the display, when 'rows' and * 'columns' have been set correctly. */ - apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); - if (old_curbuf != curbuf) - apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); + if (trigger_autocmds) + { + apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); + if (old_curbuf != curbuf) + apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); + } #endif redraw_all_later(CLEAR); @@ -3839,7 +3852,7 @@ goto_tabpage(n) } } - goto_tabpage_tp(tp); + goto_tabpage_tp(tp, TRUE); #ifdef FEAT_GUI_TABLINE if (gui_use_tabline()) @@ -3849,11 +3862,13 @@ goto_tabpage(n) /* * Go to tabpage "tp". + * Only trigger *Enter autocommands when trigger_autocmds is TRUE. * Note: doesn't update the GUI tab. */ void -goto_tabpage_tp(tp) +goto_tabpage_tp(tp, trigger_autocmds) tabpage_T *tp; + int trigger_autocmds; { /* Don't repeat a message in another tab page. */ 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 (valid_tabpage(tp)) - enter_tabpage(tp, curbuf); + enter_tabpage(tp, curbuf, trigger_autocmds); else - enter_tabpage(curtab, curbuf); + enter_tabpage(curtab, curbuf, trigger_autocmds); } } @@ -3876,7 +3891,7 @@ goto_tabpage_win(tp, wp) tabpage_T *tp; win_T *wp; { - goto_tabpage_tp(tp); + goto_tabpage_tp(tp, TRUE); if (curtab == tp && win_valid(wp)) { win_enter(wp, TRUE); |