Fix the allowed_buffers table#42
Conversation
Remove `contains` function, instead index into `allowed_buffers` to see if `buffer` should be displayed. `:TablineTabNew` with multiple buffers should now behave correctly.
`:TablineBuffersBind` was still broken in last commit due to its table format not agreeing with `Tab.allowed_buffers`. This commit corrects it.
|
Thanks so much for the PR! Yeah, I think you are right about that, I didn't test that extensively when that feature was added.
I think a unique handle would better. Somewhat related: #21
haha yeah it's also not very well documented here. I think this could be a lot more useful and powerful too, but I'll have to wait a little while before I can find time to implement some other ideas I have. |
To my knowledge, unlike tab number, bufnr is not changing once the buffer is created, so it serves as the unique handle of a buffer. Please correct me if that isn't the case. Edit: I found it non-trivial to implement that, and multiple changes in the code is required (mostly because json doesn't support integer keys directly...) |
Originally the
allowed_bufferstable of current tab, if created with:TablineTabNew, is a set with filepath as its keys andtrueas values, but if created with:TablineBuffersBind, it would be a list with filepath as its values.And the
containsfunction tests for the list-like behavior, so:TablineTabNewhas some weird behavior when called with multiple files.This PR changes
M._bind_buffers()and removescontains()to ensure thatallowed_buffersis always a set-like structure and is tested with indexes.I'd also like to ask if it's better to store bufnr (which could be get with
bufname()) instead of filepath inallowed_buffers.PS: Thank you for creating this plugin. It's embarrassing that I didn't know the "tab" part is so useful until today...