Eric Arnold wrote:
> I don't know if it's supported to do this, but I'm crashing VIm70g,
> WinXP by doing a "new" in a "TabEnter" autocommand. The crash doesn't
> immediately follow the "new" command, but soon after when other
> functions start looking through the windows.
Doing ":new" in a TabEnter autocommand is nasty, but Vim should not
crash.
> I can't get a crash in a test case, but if you run the script below,
> and if you :tabnext 5-10 times, you can see it getting real
> confused about the windows (i.e. can't :wincmd w to some of them,
> can't quit some of them).
>
> I've included a gdb backtrace from Vim70g03. It looks like the window
> list variables have been broken in eval.c.
The problem must have been caused before this, thus the backtrace
doesn't provide information about what caused it.
> P.S. What I'm trying to do is open a window
> conditionally/automatically when entering a tab. Is there a better
> way other than TabEnter?
>
>
> aug Tst_aug
> au!
> "au BufEnter * call Tst_BufEnter()
> "au BufLeave * call Tst_BufLeave()
> au WinEnter * call Tst_WinEnter()
> "au WinLeave * call Tst_WinLeave()
> au TabEnter * call Tst_TabEnter()
> au TabLeave * call Tst_TabLeave()
> aug end
>
> function! Tst_WinEnter()
> for winnr in range(1, winnr("$"))
> echomsg 'winnr=' . winnr
> endfor
> endfunction
>
> function! Tst_TabEnter()
> echomsg 'tabenter'
> new
> endfunction
>
> function! Tst_TabLeave()
> echomsg 'tableave'
> endfunction
That is a useful example. The "gt" command shows redrawing problems.
The main problem appears to be that at the moment TabEnter is triggered
there is no valid current window. I will have to swap entering the
window with triggering the TabEnter event. The sequence of triggered
events is not logical then, but it's required for a valid setup for
executing the autocommands.
Index: window.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/window.c,v
retrieving revision 1.51
diff -u -r1.51 window.c
--- window.c 3 May 2006 21:19:14 -0000 1.51
+++ window.c 6 May 2006 11:04:46 -0000
@@ -3425,19 +3425,22 @@
buf_T *old_curbuf;
{
int old_off = tp->tp_firstwin->w_winrow;
+ win_T *next_prevwin = tp->tp_prevwin;
curtab = tp;
firstwin = tp->tp_firstwin;
lastwin = tp->tp_lastwin;
topframe = tp->tp_topframe;
-#ifdef FEAT_AUTOCMD
- apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
-#endif
+ /* We would like doing the TabEnter event first, but we don't have a
+ * valid current window yet, which may break some commands.
+ * This triggers autocommands, thus may make "tp" invalid. */
win_enter_ext(tp->tp_curwin, FALSE, TRUE);
- prevwin = tp->tp_prevwin;
+ prevwin = next_prevwin;
#ifdef FEAT_AUTOCMD
+ apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
+
if (old_curbuf != curbuf)
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
#endif
--
What a wonderfully exciting cough! Do you mind if I join you?
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///