-
-
Notifications
You must be signed in to change notification settings - Fork 142
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: cache indent matches to avoid occasional race conditions #640
fix: cache indent matches to avoid occasional race conditions #640
Conversation
This fixes the issue identified in nvim-orgmode#639 Fixes nvim-orgmode#639
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we slightly simplify this by leveraging options
on the memoize_by_buf_tick
(https://github.com/nvim-treesitter/nvim-treesitter/blob/master/doc/nvim-treesitter.txt#L502) ? You can provide a custom key
where the memoization knows to use either cached result or generate a new one. Same thing is done in markup highlighter here
key = function(bufnr, line_index) |
So I'm not certain that It seems the key function has a hard requirement on using the If you know of a way to do this with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you are right. Lets go with this for now. Thanks!
…rgmode#640) This fixes the issue identified in nvim-orgmode#639 Fixes nvim-orgmode#639
This is a really weird bug. I know it's an issue with how the
get_matches
function works and buftick.indentexpr
isn't really intended for indenting many lines that all depend on each other's indents.What this does is "freeze" the matches during a indent operation against a range of lines and only updates the previous matches' indent as necessary. By doing this we get "memory" for the indentexpr of the previous indents as part of a ranged indent operation like
norm! 0gg=G
which avoids any race conditions as to the speed of indents. Without this caching theget_matches
function is called on every indentexpr operation, so for every line in the range, which can result in bad data back for calculating the indents.I have added a big ol' comment above the indentexpr with further information.
Closes #639