evil-select-parens selects next pair if not in parens
In modern versions of Vim (and Neovim), doing an action on something in parens will jump to the next instance of those parens and perform the action on them if you're not in those parens.
For example, if you are on the line int main(int argc, char **argv) { and type 0cib, it will change everything inside the parens even though you initially went to the beginning of the line. This pull request adds this functionality.
This feature already works on strings.
One bug is that if you yank something in parens and it needs to jump to the next pair because you're not in parens, in Vim it moves your cursor to the beginning of the next pair, while here it doesn't move your cursor. I couldn't figure out how to fix this.
Thanks for this! I'm in hols right now but will take a look in a couple of weeks if no one beats me to it.
@Garklein before I take a proper look, will you add some tests? I can if you can't, but it may delay things a little.
Yep, here you go!
Looks good. Two things I noticed:
-
di(doesn't move the cursor, but it should -
vi(on empty parens only selects the second paren, but it should select both (although I'm not sure if I agree with vim on this)
@Garklein I put in some fixes. I decided I'm not interested in the edge case of vi( on empty parens 🤷 - take a look if you like - I'll merge if you're happy.
@tomdl89 Thanks for fixing that yank issue, I would never have figured that out!
I found one odd edge case that I will try and fix (if either the opening or closing paren is commented out, it stack overflows) -- after that, I'm good with this merge.
Oh good spot! Yes please try to take a look - sounds a bit tricky.
@marcolgl Thank you for your contributions and thorough explanation! Everything looks good to me and I'm happy with this. @tomdl89 thoughts?
Looks great. Thanks both! That's merged to master 🚀