Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Find brackets to highlight using the Tree-sitter syntax tree #367
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.
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
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.
This improvement only takes effect for languages with Tree-sitter parsers.