todo-comments.nvim
todo-comments.nvim copied to clipboard
perf(highlight): skip redraw over folded lines
Description
Currently on a window update such as WinScroll
highlight_win is looping through every line from from w0
to w$
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: