Fix crashing on semantic tokens going past last line#833
Merged
dzhou121 merged 1 commit intolapce:masterfrom Jul 20, 2022
Merged
Fix crashing on semantic tokens going past last line#833dzhou121 merged 1 commit intolapce:masterfrom
dzhou121 merged 1 commit intolapce:masterfrom
Conversation
Member
Author
|
I realized this is an imperfect fix, because it is visible that highlighting isn't occurring until you stop typing. |
Member
Author
|
Actually I think this is fine? We don't use the results of the semantic highlighting if the revision doesn't match so there isn't actually a change. I was just noticing an existing issue of semantic highlighting not being immediate.. I think. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There is a crash where on a large project (like lapce, I typically did testing in the middle of lsp.rs) it would crash if you typed quickly (easy method: hold down enter). I believe this is a timing related crash.
This sort of fixes the issue by just stopping the processing of the semantic tokens request if there is a newer revision of the buffer. This works because we just do a full semantic tokens request each time, and so if there's newer buffer (different rev) then we can just stop processing. This is probably a minor perf benefit in of itself.
My theory as to what was happening:
I noticed that it crashed when it processed (
request_semantic_tokensfinishing) a newer revision before an older revisions request. You'd be going through a bunch of revisions as you're typing quickly.I believe RA is getting told of the new file contents before the old request has finished, and so it provides offsets for the new file contents rather than the old ones. Then those new offsets cause a crash on the old text because they go out of bounds in it.