perf(highlight): skip redraw over folded lines #304
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently on a window update such as
WinScroll
highlight_win is looping through every line from fromw0
tow$
to update the highlights. On large files with very large folded regions these two lines can be very far apart and highlighting every single line can be costly even though they are not in view. This update adds a check to skip over any lines hidden in a fold.The only minor issue I found is that there is no current event in Neovim that tells us when lines were folded or unfolded. So when a todo comment is hidden in a fold and comes to view after a fold is opened they will not be initially highlighted until an event (such as WinScroll) causes them to highlight. This can probably be fixed by highlighting a certain number of lines past the top fold (the size of the window). Let me know if you think this should be included in this pr.
Related Issue(s)
Fixes: #285
Screenshots
Looks a little choppy due to the video quality but scrolling a lot smoother, compare to video from original issue: