]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.3.551 v7.3.551
authorBram Moolenaar <Bram@vim.org>
Wed, 13 Jun 2012 12:28:20 +0000 (14:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 13 Jun 2012 12:28:20 +0000 (14:28 +0200)
Problem:    When using :tablose a TabEnter autocommand is triggered too early.
            (Karthick)
Solution:   Don't trigger *Enter autocommands before closing the tab.
            (Christian Brabandt)

src/buffer.c
src/eval.c
src/ex_cmds2.c
src/fileio.c
src/proto/window.pro
src/version.c
src/window.c

index 00d1f3535106a838bc6e91f232108c32b64b4f23..e27626eb167ccfebcdf93ea58fb0ed4fdece5b02 100644 (file)
@@ -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
 
index b0e4b31fa258be429b61623be8247cd3c3e0106d..d238dc2badba32d9cfd174f648f72a16716b21a2 100644 (file)
@@ -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;
index 611a363392844c858c8ba25c2aa7413afd21f8c4..6b12c4245acad00ed4f9225687b65ff8ed109ba1 100644 (file)
@@ -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
index 0781424689af92c1726b17e92be76eb6d65f0196..d88ff25f677bdc65b9e46233f6586433092fb429 100644 (file)
@@ -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;
                }
index d56ae1b33e07ed666ae8913df412143bc48be4d3..847b64bb5088f76709e28a651ff61791563ca1c6 100644 (file)
@@ -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));
index e3abb957c769006a72194b44831ba816929cc176..5e08bac5204d48f5fb3827057e15b8735c1432e6 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    551,
 /**/
     550,
 /**/
index ecf2aa29ab8f53c0926ef4c22efff12cb6b6cb18..f036c37cda12296635eafcd247341bd20c3cca64 100644 (file)
@@ -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);