moll / vim-bbye

Delete buffers and close files in Vim without closing your windows or messing up your layout. Like Bclose.vim, but rewritten and well maintained.
http://www.vim.org/scripts/script.php?script_id=4664
Other
654 stars 32 forks source link

Last buffer still visible with bufferline when buffer deleted with :Bd instead of :bd #14

Closed astier closed 5 years ago

astier commented 5 years ago

The bufferline-plugin shows in the airline-statusline the opened buffers. However, when I delete the last buffer via :Bdelete or :Bwipeout then bufferline still shows the name of the deleted buffer as if it still would be open. If I open another file it correctly replaces the name of the deleted buffer with the new buffer.

My assumption is that the bbye-plugin sets something wrong because bufferline works correctly if I delete the last buffer via :bdelete.

moll commented 5 years ago

What happens when you manually emulate Bbye? That is, use :enew, set a few "hidden" flags (as per https://github.com/moll/vim-bbye/blob/master/plugin/bbye.vim#L66) and then :bdelete the previous last open buffer? I don't have the ability to test it with Bufferline atm, but I can hopefully help you try debugging it.

astier commented 5 years ago

It seems to have something to do with setl nobuflisted.

  1. Open a file in nvim
  2. :enew
  3. :setl nobuflisted
  4. :bd 1 whereas 1 refers to the buffer of the first opened file

It can be observed that buffer 1 and the respective filename are still shown in the bufferlist along with the empty buffer. The buffer is however indeed deleted because it is not possible to switch back via :bn 1 and nvim throws an error if I try it as you can see it in the screenshot. bufferlist_bug The same result occurs when I also include the other steps from the link you have send me. However, only :setl nobuflisted causes it. If i leave it out it works as expected.

Note that if I use :Bd directly only one buffer is shown in the bufferline with the name of the deleted buffer instead of two buffers (old and new).

moll commented 5 years ago

Well done on pinpointing the problem. I think this hints toward it being Bufferline's anomaly rather than Bbye's, given Bufferline should update its list of open buffers properly in the presence of unlisted ones.

astier commented 5 years ago

Agree. Probably its caused by bufferline. Unfortunately it sees like the project-owner does not maintain it anymore.

moll commented 5 years ago

I don't think it was a very large project, so with your insight above, you may be able to fix it yourself. I've been using https://github.com/ap/vim-buftabline for a few years myself. You're welcome to ditch Bufferline and pick that one. Makes more sense IMO to have a single wide bar at the top that jam open files to the constrained space that is a single file footer. Especially if you have two files open side by side — the workflow Bbye.vim fixes. Although Buftabline's README states Airline, the plugin you're using to drive Bufferline, already supports showing buffers separately...

astier commented 5 years ago

I just figured out that airline ships already with its own built-in extension called tabline and I switched to it. Works very good with bbye and definitely better than bufferline. Also has mouse-support and is very configurable. Thank you for your help :)