rebelot / heirline.nvim

Heirline.nvim is a no-nonsense Neovim Statusline plugin designed around recursive inheritance to be exceptionally fast and versatile.
MIT License
968 stars 38 forks source link

Buffers not displayed in buffer number order #146

Closed moonlitknight closed 1 year ago

moonlitknight commented 1 year ago

During an edit session with buffers being opened, closed, reopened, I end up with a buffline that contains a list of buffers that are not in buffer number order. The effect of this is that the keys I have mapped to :bnext and :bprevious don't move sequentially left and right through my displayed buffers.

I suspect this is due to me frequently opening and the :bdelete ing buffers. If I reopen a previously :bdeleted buffer, it uses the original buffer number. Eg.

open A
open B
open C
:bdelete B
open B

results in a buffline of A C B whereas :buffers displays 1 A 2 B 3 C

Is there any way to have the list always sorted by buffer number?

Apologies for the slightly vague issue report. I'm using AstroVim 3.1.1 so I guess it's AstroVim that is setting up the bufferline.

As a workaround, I've found that using :bwipeout rather than :bdelete preserves the logical ordering as the subsequent open creates a new buffer number rather than reusing the previous number.

rebelot commented 1 year ago

What you describe would be the default behaviour of heirline, but I think AstroNvim uses a customised buf_func to get the opened buffers and manage the cache. Perhaps we should hear from @mehalter

mehalter commented 1 year ago

Thanks for pinging me with this @rebelot . Yeah we do have a custom buffer function and we do not preserve buffer number order by default. It is ordered by when the buffers were opened. But we do have sorting functionality for sorting based on buffer number, modified date, full path, file name, etc. I replied to this in the issue on AstroNvim. I believe you can close this issue here.

rebelot commented 1 year ago

Thanks for stepping into this! @mehalter