Closed thecoolwinter closed 1 year ago
Closing this because the includedRanges
parameter doesn't apply to this problem well. If we were to use it to try and make editing faster, the syntax tree tree-sitter
creates will be incomplete and buggy. It will also not shrink if the includedRanges
shrink, so the editing time improvement will be nonexistent for larger files where it matters.
Instead, we should look into backgrounding long edit times using the timeout
parameter on parsers. Swift's async/await would be perfect here.
Description
SwiftTreeSitter provides a
includedRanges
array binding to the tree-sitter parser that would allow us to set what ranges tree-sitter acts on. Right now, tree-sitter parses the entire document when initialized. This isn't a huge problem, as it's very fast and by a quick tests parses very large files in only a few milliseconds. However, this is still a large inefficiency and something that should be implemented.What would need to be done:
Highlighter
to provideHighlightProviding
objects with the "effective range", basically thevisibleSet
we already calculate.TreeSitterClient
to use the effective range and to update the ranges in real time.