Vim-airline: Tab line doesn't refresh when I delete a buffer

Created on 3 Jan 2014  路  36Comments  路  Source: vim-airline/vim-airline

It seems that when I have multiple buffers open (and they are displayed in the tab line) and I issue a buffer deletion on a buffer when I'm currently on a different buffer (:bd 3 to delete a buffer of ID 3 for example while I'm currently focused on buffer ID 1) the tab line doesn't refresh and remove that "tab". Issuing a :bnext _does_ cause the tab line to refresh, and "tab" 3 disappears. Not a huge issue, but it would be nice if that tab would automatically be removed upon the initial delete. I recall a few months ago (before I recently updated) that this was the behavior.

Just to be clear, the buffer really does get deleted successfully (:buffers shows that buffer ID 3 is gone) but the tab in the tab line still shows until I cycle to another buffer.

  • MacVim Snapshot 72 on Mavericks
  • Latest version of Airline on master
  • Replicated the issue with Airline being my only Bundle installed

Thanks!

bug tabline

Most helpful comment

adding

autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate()

to .vimrc and it works

All 36 comments

+1.

+1

+1 Haha Lemme watch this post.

+1. This is why I disabled the tab line extension since it was too confusing.

I still got the same problem. When i open a new tab (existing one) and then close, it still stays in the tab line.

+1.
Disabling the bufferline until resolved

Also having this issue, it this a regression?

+1
Also having this issue.

+1
need more test, sometimes I also get this issue

Is this the same issue?
When I close tabs :tabclose when the only one tab remains tabline shows 'ghost' tabs.

2 additional tabs open:
img

2 tabs closed:
img

Check with :b if the buffers are still available.

Hi @chrisbra,
Oh, I see, it shows buffers when no tabs are open. Haven't noticed the title on the right.
And from the documentation, it can be disabled with let g:airline#extensions#tabline#show_tabs = 0
Thanks!

+1

+1 and im using vim 8

+1 Issue still persists with neovim.

After :bdelete it still exists in the tabline, but not in the :bufferlist.
After opening the "deleted" buffer with a click on the tabline, the tabline disappears, the buffer is opened but does not appear in the bufferlist.
If more than one buffer is deleted in sequence, everything is fine except the last deleted buffer, which shows the same described behaviour.

If I continue to work with the "ghost" buffer (opened by clicking in the tabline on a "deleted" buffer) crashes neovim.

I think the reason is this:

The

BufDelete           Before deleting a buffer from the buffer list...
function! airline#extensions#tabline#buffers#on()
  augroup airline_tabline_buffers
    autocmd!
    autocmd BufDelete * call airline#extensions#tabline#buffers#invalidate()
    autocmd User BufMRUChange call airline#extensions#tabline#buflist#invalidate()
    autocmd User BufMRUChange call airline#extensions#tabline#buffers#invalidate()
  augroup END
endfunction

The call to the invalidate function refreshes the buflist, but the buffer is not yet deleted, because the autocommand triggers before the deletion of the buffer. This would explain the behaviour described in my last post.

adding

autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate()

to .vimrc and it works

@BonarBeavis it works thanx

@chrisbra
I use au TermClose * exe expand('<abuf>').'bd!', so when I type Ctrl+d in neovim's terminal buffer, the tabline will change from bash to [No Name].

here is a video:

asciicast

I don't use neovim. But isn't this the expected behaviour?

yeah, it is not. Should not has No Name tab.

I think you are wrong. You are closing the terminal, and the next file opened in the current window will be buf-deleted so (n)vim will open a new unnamed buffer. And that is what you are seeing.

no, I use bd to delete terminal buffer. nvim should move to another exists buffer. instead of create a new one. BTW :ls! do not has new buf

I think it is due to bd! on TermClose do not send a bufdelete autocmd.

official update for this issue????

@tracyone what is the issue? I have fix it my self.

@BonaBeavis's trick works but I don't understand why updating the tab- or buffer-line is not a default behavior upon removing the buffers?

It is unclear what this issue actually is. Is this only relevant for Neovims terminal and the TermClose event? Or is there a way to reproduce it with normal buffers?

@BonaBeavis's trick works but I don't understand why updating the tab- or buffer-line is not a default behavior upon removing the buffers?

It is (here and here)

@chrisbra I can confirm that it's not a Neovim issue because same thing happens to me in Vim. I'm not sure if it has to do with vim-ctrlp. When I directly run :bd on a single buffer, the tabling gets updated correctly without using @BonaBeavis's trick. When trying to close multiple buffers with vim-ctrlp, I have to have autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate() to get the desired behavior.

I'm also a bit confused about the differences among #tabline#buffers, #tabline#tabs, and #tabline#buflist...

When trying to close multiple buffers with vim-ctrlp, I have to have autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate() to get the desired behavior.

So how to reproduce?

This issue is definitely NOT fixed. I had to use the line provided by @BonaBeavis:

autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate()

@bling Can we re-open this issue?

@bling Can we re-open this issue?

Do you mean me? Please come up with a reproducible example.

@chrisbra It is pretty simple to reproduce. Let's say I have three buffers:

1 A.sql
2 B.sql
3 C.sql

I have the following airline settings:

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#tab_nr_type = 1
let g:airline#extensions#tabline#buffer_nr_show = 1

I can see 3 buffers in the tabline. Buffer 1 is active in the only window open. Then I do the following:

:2bd

or

:bd 2

Buffer number 2 still appears in the tabline, but does _NOT_ appear when executing the :buffers command.

But, if I add this to my vimrc, the buffers are removed from the tablne as expected:

autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate()

This is with NeoVim 0.3.0.

Perhaps it was fixed at one point, but reappeared in later versions?

I am also able to reproduce this in Vim 8.0.

thanks. Please try current head

@chrisbra Updated to current head. Now works correctly in NeoVim 0.3.0 and Vim 8.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brotatos picture brotatos  路  21Comments

liuchengxu picture liuchengxu  路  16Comments

ravicious picture ravicious  路  22Comments

svanharmelen picture svanharmelen  路  22Comments

svanharmelen picture svanharmelen  路  38Comments