kdheepak/tabline.nvim

Use tabpage handle rather than tabpage number as keys in `tabline_tab_data`

gkzhb opened this issue · 6 comments

gkzhb commented

The plugin is using tabpage number as keys in tabline_tab_data.

The tabpage number of a tab A will be changed if the tab B whose tabpage number is less than A's is removed. Thus the tabline_tab_data key-value mapping won't be correct after this kind of tabpage deletion.

We should use tabpage handle which is a unique identifier for the tabpage

Neovim provides nvim_set_current_tabpage(), nvim_get_current_tabpage(), nvim_list_tabpages() and api-tabpage APIs that uses tabpage handle. We can also utilize the tab-scoped variables to store data specific to a tabpage to avoid global tabline_tab_data

Thanks for reporting that issue! I didn’t know about that. I’ll update the plugin accordingly.

gkzhb commented

Well, I find a situation that we should pay attention to. The sessions in neovim don't store tabpage handles. As a consequence, when reopening a session, all tabpage handles are reassigned.

One solution I find is that we can store tabpage number in tab data so that we can remap the tabline_tab_data with tabpage number. And this should be done when SessionLoadPost autocmd event is triggered.

nesqi commented

Maybe you can have a look at my attempt to fix this?
It works for me but probably not with sessions as tab local data doesn't seem to be stored. Maybe that can be fixed somehow?

Thanks for making a PR! I unfortunately won’t have time to look into this until this weekend, I can look into it then.

nesqi commented

Thank you for writing the plugin!

Don't, stress. I think it might be possible to store the tab-data in a global variable that is saved by :mksession and then also register an autocmd to read the data back on session load. Looking at other plugins this seems to be how you do it. So I might update with such a fix as well.

So there is no immediate rush to merge the patch. I was rather looking for input on improvements or issues.

nesqi commented

Fixed session support and initial naming of tabs.

https://github.com/nesqi/tabline.nvim