Skip to content

🐞 tree-sitter Parsing Inefficiency #143

Closed

Description

@thecoolwinter

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:

  • Add a way for Highlighter to provide HighlightProviding objects with the "effective range", basically the visibleSet we already calculate.
  • Modify TreeSitterClient to use the effective range and to update the ranges in real time.

Activity

  1. moved this from 🆕 New to 📋 Todo in CodeEdit Projecton Feb 16, 2023
  2. thecoolwinter commented on Mar 16, 2023

    @thecoolwinter
    CollaboratorAuthor

    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.

  3. moved this from 📋 Todo to 🏁 Complete in CodeEdit Projecton Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions