Christian Brabandt wrote:
> 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.