akinsho / bufferline.nvim

A snazzy bufferline for Neovim
GNU General Public License v3.0
3.5k stars 196 forks source link

Improve tab navigation with truncate filename set to false #534

Open ray-x opened 2 years ago

ray-x commented 2 years ago

There are 2 cases that can be improved.

There is no way I can use mouse to move to the next buffer. I have to use bnext/bprev (also BufferLinePick not working as only one tab is shown)

Is it possible to show at least 2 tabs and the behaviour is this (suppose I have 5 files and 3 of them are shown) | long_file... | long_file_name_file_3 | long_file... | If I click on long_file... on the right, it will be | long_file... | long_file_name_file_4 | long_file... | If I click on long_file... on the left, it will be | long_file... | long_file_name_file_2 | long_file... |

Originally posted by @ray-x in https://github.com/akinsho/bufferline.nvim/issues/533#issuecomment-1235409058

akinsho commented 2 years ago

Ah right, so I don't think this is actually a bug, just a possible improvement that is brought to light by using long filenames.

This is actually quite hard to improve, the reason being that this plugin works by calculating the size of all tabs and then truncating it till they all fit. There's no edge case handling like if the long file name in case 1 is bigger than empty_space 1 and 2 there's nothing to be done. It gets removed. Same with the second case, if 2 buffers with long names won't fit there's no way to ensure that at a small width they fit, there's either enough space or there isn't. That's the current mechanism.

Because of #413 I have been considering completely changing the strategy for how to decide what fits into the tabline or not, but this is quite complex because I need to figure out some other algorithm for deciding what to show and what not to show.

I think the solution I will eventually use will be to change the algorithm to just truncate at the edges, so you will end up with buffer cut in half if they don't fit, but I'm not sure if I like this UI.

Anyway TLDR is this is quite a hard request that will probably have the same solution as #413 I might open an umbrella issue and close both issue but reference the problems in the umbrella issue for a potential refactor.