Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Fix the allowed_buffers table #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

s-cerevisiae
Copy link
Contributor

Originally the allowed_buffers table of current tab, if created with :TablineTabNew, is a set with filepath as its keys and true as values, but if created with :TablineBuffersBind, it would be a list with filepath as its values.
And the contains function tests for the list-like behavior, so :TablineTabNew has some weird behavior when called with multiple files.

This PR changes M._bind_buffers() and removes contains() to ensure that allowed_buffers is 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 in allowed_buffers.

PS: Thank you for creating this plugin. It's embarrassing that I didn't know the "tab" part is so useful until today...

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.
@kdheepak
Copy link
Owner

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'd also like to ask if it's better to store bufnr (which could be get with bufname()) instead of filepath in allowed_buffers.

I think a unique handle would better. Somewhat related: #21

PS: Thank you for creating this plugin. It's embarrassing that I didn't know the "tab" part is so useful until today...

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.

@s-cerevisiae
Copy link
Contributor Author

s-cerevisiae commented Apr 20, 2022

I think a unique handle would better.

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...)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants