-
-
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
Make m
textobject look for pairs enclosing selections
#3344
Make m
textobject look for pairs enclosing selections
#3344
Conversation
This behavior feels intuitive to me as you say 👍 I think the tests don't need any adjustment because there aren't cases yet that cover this behavior. It would probably be good to add one or two that have different behavior between this and master |
I implemented a test and identified that it was missing some cases. In particular, if the start of the selection was before the opening pair it would reduce the selection down. I tried modifying the logic, but now in that case it simply fails to find a matching pair at all.. I've been banging my head against the desk for an hour, so I have to step away from this. Any help would be appreciated. |
The function you modified is
|
Thanks so much! My next hacking session on this might not be for a little while but I should be a lot more productive on it now |
3aaacfa
to
41b484d
Compare
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.
Can we split these tests out into helix-term/tests/test/movement.rs
or at least add a few cases there? mam
/mim
could really use some overall tests and the tests should end up being easier to read because of the selection DSL
I could take a stab at that. |
fca2dc4
to
ca4fe1b
Compare
Tests have been translated over to the new integration system, but they're still not passing. Ran out of time to work through correctness issues with test cases. Will come back later. |
There's an issue with the PR and counts that I need to address, and staring at the code some more I think there's some more simplification to do. |
ca4fe1b
to
9cfdf4c
Compare
Tests all pass now, the trouble was with the skip logic. There remains the pathological case of when a single character cursor is on the opening of a pair, but that was an issue prior to this refactor and should be left for a separate fix. The new tests should help a lot with such an endeavour. |
f285550
to
2c070cb
Compare
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.
The code looks good to me, thanks for the improvement! I'm assuming this code affects the "around" motions too. Would you be able to add ma
tests that complement the mi
tests?
I can do another pass on tests yeah. |
Looks like the code fails some lints, can you run |
Yes I can, also intended to write the |
2c070cb
to
812dffd
Compare
@archseer Added the |
Reading through that it doesn't actually appear this PR addresses any of the several issues identified. Can you enlighten me?
At this point this PR has been sitting for a while. I'd rather see that issue with the opening bracket fixed in a follow-up. Feel free to work on that on your end.
100%. When I started work on this the conceit was I would quickly resolve the non-tree-sitter version and then move on to working on the tree-sitter version. Didn't end up getting that far.
I won't be able to spend a lot of time on helix contributions for a while, go for it! |
@archseer any chance this makes it into the release? |
Oh, sorry but I completely missed this PR. I'm only merging small changes or bugfixes this close to release, but it'll definitely make it into the next cycle! |
21f14a9
to
085e3aa
Compare
Lint issue is unrelated to changes in this PR. |
Seems like a2ad2e6 deleted some indents rustfmt wants |
085e3aa
to
eb953c3
Compare
Right now, this textobject only looks for pairs that surround the cursor. This ensures that the pair found encloses each selection, which is likely to be intuitively what is expected of this textobject.
Co-authored-by: Michael Davis <[email protected]>
Prior, it was missing the case where the start of the selection came before the opening brace. We also had an off-by-one error where if the end of the selection was on the closing brace it would not work.
eb953c3
to
5b68034
Compare
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.
Sorry for the delay, let's get this merged! I'm liking the new integration tests and the main change in find_nth_closest_pairs_pos
looks good 👍
Right now, this textobject only looks for pairs that surround the cursor. This ensures that the pair found encloses each selection, which is likely to be intuitively what is expected of this textobject.
I'm marking this as a draft because I haven't adjusted the tests to expect the new behavior, and I'm not 100% sure all the edge cases are covered. I wanted to maybe get eyes on it to help me find them.