karb94 / neoscroll.nvim

Smooth scrolling neovim plugin written in lua
MIT License
1.46k stars 36 forks source link

zz causes flickering in the end of file with wrapped lines #95

Closed AndreiNekrasOn closed 7 months ago

AndreiNekrasOn commented 8 months ago

I came into this issue randomly, and was able to reproduce it only on a specific file. When I move into the last line of the file that has wrapped lines and call zz, the scroll starts flickering.

neoscroll-bug

How to reproduce:

long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line

short line short line short line short line short line short line short line short line short line short line short line short line short line short line short line short line short line


- `G`, `zz`

I think this has something to do with `wrap` option: the bug occurs when the wrapped line ends up at the top of the screen. Unfortunately, I don't know neovim enough to debug it further.
karb94 commented 7 months ago

I think I fixed this with 21d5297. Can you confirm?

The issue was that wrapped lines sometimes force you to scroll more lines than necessary and Neoscroll would try to backtrack which could result in an endless loop. Backtracking is not something it should do anyways so this change prevents backtracking one overshooting the target line.

AndreiNekrasOn commented 7 months ago

Yes, now this works as expected.