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

[Fix]: Don't mark all lines in buffer as dirty, only visible lines #155

Closed
wants to merge 1 commit into from

Conversation

sandersantema
Copy link

In the original code all of the lines in the current buffer are marked as dirty. I don't know whether filetypes which have treesitter support suffer from this too but for a big buffer and a filetype such as xml this gets very slow to the point where it blocks neovim for a while until it's done. This happens too after the latest performance commits but I don't know if they were relevant.

This pr is a simple change which makes it so that only the currently visible lines in the buffer are redrawn. I'm opening this pr as a draft because I'm only using a very limited subset of this plugin's features so I don't know if anything besides simply highlighting is impacted by this. Consider it a issue report with an included preliminary fix.

If you're interested I've got a stack trace too, although the only thing it really shows is todo-comments.highlight.match being called 45000 times for every line of my large xml document.

Other than that, hartstikke bedankt for all the fantastic work Folke! Greetings from up north :)

@sandersantema sandersantema changed the title don't mark all lines in buffer as dirty, only visible lines [Fix]: Don't mark all lines in buffer as dirty, only visible lines Nov 8, 2022
@sandersantema
Copy link
Author

I believe you might have intended last to be:

last = math.min(last + Config.options.highlight.multiline_context, vim.api.nvim_buf_line_count(buf))

Instead of:

last = math.max(last + Config.options.highlight.multiline_context, vim.api.nvim_buf_line_count(buf))

Otherwise last would always have a value equal to the line count of the buffer or larger.

@folke folke closed this in bca0e00 Nov 8, 2022
@folke
Copy link
Owner

folke commented Nov 8, 2022

omg, inderdaad! Stomme fout van mij :)

Net gefixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants