-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(core): match inside/around closest pair inconsitency #10611
base: master
Are you sure you want to change the base?
Conversation
209c6ca
to
2810946
Compare
@thomasaarholt I fixed your remark, I didn't notice anything strange anymore. Feel free to test it out if you wish. |
Sweet! I'll try to test this this evening and quickly get back to you - out for the day! |
The direction of a single width selection doesn't matter/is essentially ab implementation detail hidden from the user. Even if its sometimes backwards internally it should always be forward for single width selections sk thay behavior is intentional |
I was wondering about the pairs in Markdown, for example
does not Also, in markdown, select a word and |
the markdown case is caused by the fact that markdown handles these pairs as injections and while there is some basic support for injections in match bracket its very very basic and doesn't handle these cases yet. I am working on larger changes to TS that would cover this |
actually I wanted to go in the opposite direction here and make |
@woojiq I think this was mostly a miscommunication on my part/skipping past that comment by accident. I think you just need to turn |
Thanks for the clarification. The problem is that if I add "-1" than if we are already "around" some pair (hit "mam") then one more "mam" will do nothing and you have to type "2mam" or move the cursor. This seems logically, but from personal experience I think that each subsequent "mam" should expand to the next pair, while "mim" should not (this is how it worked before my commits) |
This could theoretically be useful. I think this may have been an oversight in the PR that changed However, for consistency if we are going to change that we should change it for all textobjects consistently. I think for now we should just make |
I managed to fix all the bugs that were caused by |
9bf10fa
to
0890141
Compare
I think I achieved the desired behavior. I'd ask y'all to give it a try (especially on edge-cases) and tell me if you think this behavior is acceptable. It feels good for me. <description and commit message was updated> |
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.
Great! This is now acting the way I expect it to! Thank you very much for fixing!
Any chance we can include it in the next release? Because the matching around/inside on master (on 24.03 it's ok) is slightly broken and everyone will have it with the next release. |
Make tree-sitter version of matching inside/around to replicate current behavior of plaintext files. That is: * match around - always tries to extend a selection to the next pair, even when the selection is already around a pair. * match inside - do not extend a selection when it already completely matches the pairs.
0890141
to
cb5688c
Compare
Fixes one inconsistency missed in #8294
Make tree-sitter version of matching inside/around to replicate current behavior of plaintext files.
That is:
even when the selection is already around a pair.
matches the pairs.
Not related directly to this PR
Also, I noticed that if we have a selection with len=1, then "head" is always larger than "anchor" (even if we just moved one character to the left), and as a result
mim|mam
does not preserve direction in such cases. @pascalkuthe, Is this the intended behavior? With a selection of len>1 "anchor" and "head" are correct.Though in my new tests everything is ok, probably because the
#[| ]#
creates the correct "Range".Answer: #10611 (comment)