Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(highlight): skip redraw over folded lines #304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtrajano
Copy link

@mtrajano mtrajano commented Jul 26, 2024

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:
Screen Recording 2024-07-26 at 1 56 46 PM

Fixes: folke#285

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.
@mtrajano mtrajano changed the title perf(highlight): Skip redraw over folded lines perf(highlight): skip redraw over folded lines Jul 26, 2024
Copy link
Contributor

This PR is stale because it has been open 30 days with no activity.

@github-actions github-actions bot added the stale label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: performance issues on large files with folds
1 participant