This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Find brackets to highlight using the Tree-sitter syntax tree#367
Merged
maxbrunsfeld merged 5 commits intomasterfrom Nov 20, 2018
Merged
Find brackets to highlight using the Tree-sitter syntax tree#367maxbrunsfeld merged 5 commits intomasterfrom
maxbrunsfeld merged 5 commits intomasterfrom
Conversation
65e1dd1 to
a38dc3f
Compare
maxbrunsfeld
commented
Nov 17, 2018
| } | ||
| }) | ||
| if (startRange && endRange) return {startRange, endRange} | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This one method takes the place of the the TagFinder class.
This was referenced Nov 20, 2018
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description of the Change
Currently, this package finds matching brackets by performing a regex search and keeping track of the nesting level of bracket characters. The code for finding matching HTML tags is even more complicated.
In this PR, I've updated the package to find matching tokens using syntax trees provided by Tree-sitter, when they are available.
Benefits
The performance of bracket matching is vastly improved. Here's a flame graph that I recorded in the current version of Atom when moving the cursor across this opening parenthesis in Atom's
text-editor-component-spec.js.This operation took 300ms.
Here's a flame graph that I recorded of the same operation with this fix:
The operation now takes 0.75ms; the syntax tree makes the operation basically free.
Possible Drawbacks
This improvement only takes effect for languages with Tree-sitter parsers.
Applicable Issues
Fixes #348
Fixes #355