randymorris/vim-bufstat

Statusline does not always show active file

Closed this issue · 8 comments

When many buffers are open, the statusline does not show the first buffers, even if we edit these files.

This is due to the static type of the status line mangeled by "<" when many buffers are open.

This is due to the fact vimscript does not provide a way for me to get the length of the user configured statusline. Without this information I have no way to guess which buffers I can show and I never know where bufstat's portion of the statusline is cut off.

I'd like some input from anyone using this script as to the best way to handle this. Personally I never have more than a few buffers open so I never/rarely have this issue.

Any thoughts?

I think the buffer list should be reordered with the current file at last and the alternate file as previous to last
the numbers will not be increasing but then we have the information we need
you can do this independently of statusline length

PS: thanks for the quick reply

I think the best way to go here would be to provide a 'sorting hook' that the user can define via a global variable. This would allow me to provide a couple of default sorting functions but allow anyone to write their own. It makes bufstat more complex than it really needs to be, but it adds lots of flexibility.

Any objections to this?

I'll think it over for the next few days and maybe push a proof of concept up to a temporary branch over the weekend. If the code gets too ugly I'd rather just try to pick a good default sorting function and hope it satisfies most users.

That sounds really nice!

Just pushed this to the sorting branch. Want to give it a test run? I believe the sort function you'll want is BufstatSortReverseMRU.

Edit: Just realized it's going to take a bit of work to get this to work with > 1 window. Feel free to check it out though.

Edit2: It actually probably does work for > 1 window, just doesn't save the most recently used buffer order per window. I think this may actually be a better way to handle it.

nice, I shall try tomorrow and let you know

sure it will give the best status bar ever :-)
Le 21 avr. 2011 20:39, "rson" <
reply@reply.github.com> a
écrit :

Just pushed this to the sorting branch. Want to give it a
test run? I believe the sort function you'll want is
BufstatSortReverseMRU.

Reply to this email directly or view it on GitHub:
#1 (comment)

It's working exactly as expected and solved my problem!

Thanks a lot for the great job (and nicely done with the option to specify dedicated sort algo)

That's fine for me to merge it into master.

Thanks for the feedback.