-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve match bracket matching #10613
improve match bracket matching #10613
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rebase my changes on top of yours to see if they work together.
Unfortunately I can't review your PR properly because I don't really know how to work with the tree-sitter API, I used only helix's wrappers around TS in my commits)
Brilliant! In Markdown words surrounded in backticks now work everywhere, and also all the individual matching pair elements (
For reasons unknown to me you can
Not that big a deal, but I thought I would mention it in case it was a bug. |
Type |
68d6677
to
3049692
Compare
Markdown seems to be just a weird case its grammar the quotes there are not actually part of the sytnax tree (they are really just plaintext). The inline grammar that markdown uses is pretty hacky and the way it seems to produce nodes... Frankly doesn't make much sense. I think it works this way because of TS limitations/because markdown really isn't all that suited to a proper syntax tree but its mostly a coincidence that is works sometimes at all that is down to implementation details of the language.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this with #10611 on top, only with Python. Everything works as expected. Nice work, and thanks for fixing!
Can we add some unit/integration tests for the bugs being fixed? |
3049692
to
d9bf297
Compare
@archseer good point I added a couple integration tests both for past edge-cases and the new cases I fixed |
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This PR fixes a couple of edgecases that were noticed in the match bracket implementation after the recent changes to match_bracket.
This should cover both the markdown cases discovered by @David-Else (although I think there are still some cases involving injections that may not be covered but all the examples discussed work now) and the python cases discoreved by @ thomasaarholt. I also included fixes for some issues for cases where in cases where multiple nested pairs are siblings. I think this probably shouldn't happen usually, but it can happen in case there are syntax error so it's nice to be a bit more robust