nvim-scrollbar
nvim-scrollbar copied to clipboard
[Bug Report] Bar first increases in size before moving
I noticed when scrolling, that the bar first increases in size in the scrolling direction before moving and decreasing to its previous size. I suspect this is not intended behavior and looks somewhat wanky, with the bar wobbeling along while scrolling. This may be due to scrolloff, but I didn't have time yet to narrow down the issue.
I noticed this too, looks a bit odd. It's amplified when using https://github.com/psliwka/vim-smoothie:
https://user-images.githubusercontent.com/6705160/148556423-3060db26-3c3d-4e2b-8571-32749693beda.mov
Lines seem to cut the scrollbar a bit weirdly too (here's with both wrap
and nowrap
):
https://user-images.githubusercontent.com/6705160/148556597-d467811e-2131-48b1-b1c6-c8d6eb78e74c.mov
I'll have to investigate a better way of calculating the handle length. Might just need to separate this out of the render function
I guess the reason is that the relative_first_line
and relative_last_line
are rounded down so the difference of them, aka the height, is unstable. It may differ 1 when window scrolls.
local ratio = visible_lines / total_lines
local relative_first_line = math.floor(first_visible_line * ratio) - math.floor(1 * ratio)
local relative_last_line = math.floor(last_visible_line * ratio)
-- correct the folding diff
relative_first_line = utils.fix_invisible_lines(folds, relative_first_line, first_visible_line)
relative_last_line = utils.fix_invisible_lines(folds, relative_last_line, first_visible_line)
So I made a pr which may solve this.