Re: Tab Order

22 views
Skip to first unread message

Christian Brabandt

unread,
Jun 9, 2012, 8:41:33 AM6/9/12
to vim...@googlegroups.com, vim-dev Mailingliste
Hi Ben!

On Do, 07 Jun 2012, Ben Fritz wrote:

> On Thursday, June 7, 2012 9:09:16 AM UTC-5, Karthick wrote:
> > I tried doing this and ran into an issue..
> >
> > The script:
> > au TabEnter * call TabEnterFunc()
> > au TabLeave * call TabLeaveFunc()
> >
> > func! TabEnterFunc()
> > echo 'Enter: ' . tabpagenr("$")
> > sleep 1
> > endfunc
> >
> > func! TabLeaveFunc()
> > echo 'Leave: ' . tabpagenr("$")
> > sleep 1
> > endfunction
> >
> > If a new tab is created with:
> > :tabnew
> > the prints are,
> > Leave: 1
> > Enter: 2
> > (i.e, the number of tabs on TabEnter is one more than when TabLeave
> > triggered). This is good.
> >
> > But when we quit a tab with :q, we get,
> > Leave: 2
> > Enter: 2
> >
> > Shouldn't the number of buffers as returned by tabpagenr("$") be
> > up-to-date by the time TabEnter gets triggered?
> >
> > :version
> > VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22)
> > MS-Windows 32-bit GUI version with OLE support
> > Compiled by Bram@KIBAALE
> > Big version with GUI.

Bram,
the problem is, that enter_tabpage() is called when still both tabpages
are valid (before freeing that tabpage), so tabpagenr() returns the
wrong number in case of the :tabclose command.

Attached is a patch, that fixes it.

regards,
Christian
tabenter_autocmd.diff

Bram Moolenaar

unread,
Jun 9, 2012, 10:03:18 AM6/9/12
to Christian Brabandt, vim...@googlegroups.com, vim-dev Mailingliste
Thanks, I'll check it out.

--
"So this is it," said Arthur, "we are going to die."
"Yes," said Ford, "except...no! Wait a minute!" He suddenly lunged across
the chamber at something behind Arthur's line of vision. "What's this
switch?" he cried.
"What? Where?" cried Arthur, twisting around.
"No, I was only fooling," said Ford, "we are going to die after all."
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages