TextArea improvements - lazy language import and allow installation of only required languages #5639
+125
−154
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.
Launching TextArea with the
syntax
extras has a large upfront cost the first time it's run in a new virtualenv.A one-off compilation step is performed when the language is imported, and since all languages were being imported at the module level, it was adding a 1-2 second overhead at startup on the first run.
Subsequent launches within the same venv had little overhead (a few milliseconds).
Lazy importing of tree-sitter languages
This PR updates the TextArea to lazily import the languages, only when they're used, trimming 1-2 seconds off of these "cold starts".
Allowing users to install only what they need
With this PR, users don't need to install the
syntax
extras which includes a bunch of languages. They can instead just installtree-sitter
plus the languages they require.For example, with Posting I uninstalled the syntax extras then done this:
...and it just worked without any code changes. Apps no longer need to pull in a bunch of transitive dependencies that they don't need.
Please review the following checklist.