Unexpected surround match when cursor is on quote character (not inside) #1726
-
Contributing guidelines
Module(s)mini.surround QuestionHi! I’m encountering a confusing edge case with mini.surround related to how it matches quotes when using the change surrounding functionality. 💡 The scenario: Given this line of Lua code:
I want to change the surrounding quotes around When my cursor is inside the quotes, everything works as expected: However, when my cursor is on one of the quote characters (either the opening ' or the closing '), the match behaves unexpectedly: Video below helps demonstrate using surround-find ' mini-surround-help.mp4🔍 What I’ve tried: I’ve experimented with the following search_method settings: But none of these change this behavior when the cursor is on the quote character. It’s only when the cursor is inside the quoted string that the behavior works correctly. ❓ Expected behavior: Ideally, I’d expect the plugin to treat being on a quote the same way as being inside the surrounded region — i.e., to detect and operate on the closest enclosing pair, not jump to earlier or later matches. Is this intended behavior? Is there a way to ensure that when the cursor is on a quote, the plugin still finds the enclosing pair instead of looking elsewhere? Thanks for the great work on all these amazing plugins! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, this behavior is expected, albeit not mighty intuitive. This is a result of a combination of the following:
The solution that works here is to create a custom surrounding for require('mini.surround').setup({
custom_surroundings = {
["'"] = { input = { "%b''", '^.().*().$' } },
}
}) |
Beta Was this translation helpful? Give feedback.
Yes, this behavior is expected, albeit not mighty intuitive. This is a result of a combination of the following:
'a' b 'c'
with cursor onb
the surrounding would be from right'
in'a'
to left in'c'
. This has always been the case in 'mini.surround'. I remember thinking about changing it by default and deciding not to do it, but to be perfectly honest I don't remember the reason (beside obvious "this is a breaking change"). It is probably due to'
being frequently used in plain English and having it balanced is problematic; while also hav…