-
-
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
surround as selection #368
Conversation
A selection first implementation is what I tried at first too since it's more aligned with helix's editing model, but there are some problems:
How are you planning to change the way adding surround pairs work ? Does it use Here's the previous discussion regarding the selection first approach - #320 (comment). |
Thanks for your reply!
For surrounding the match: Then we introduce a key pair for placing cursors inside/outside of a selection.
This would also fit with the rest of the movement/selection concept. |
I will think about your answers, also have some crazy ideas to test :) Will be going out for pre-midsummer celebration now here in Sweden. Happy midsummer! |
@bonega we're also on matrix if you want to drop in and say hi ;) https://matrix.to/#/#helix-editor:matrix.org Happy midsummer to you too :) |
This looks very cool! The codebase has diverged enough that dealing the the merge conflicts looks like it would be non-trivial, as the implementation of With that said, the core of the logic looks intact, and I don't think it would be a lot of work to redo the match-mode changes. @bonega do you have any interest in picking this back up? It looks like a nice quality-of-life change, and possibly more extensible than the current match-mode logic. |
@AloeareV Thanks for the comments! I like to revisit this issue given enough time 👍 |
Is this pull request still valid? I didn't look closely but IIRC @sudormrfbin did some work around this. |
Closing as stale. Feel free to re-open the PR if you ever want to continue. |
I am proposing an alternative to at least part of match-mode.
Current implementation has one big drawback:
It doesn't visually show what text will be affected(VIM way).
My implementation fixes this, but has a very different design.
Solution:
m
followed by match-char will make a selection of nearest enclosing pair by counting open/close.example with brackets being cursor position:
Some (text (here)[ ) ]
Pressing
m(
will result inSome [ ( ]text (here)[ ) ]
Now we have two normal cursors, so all commands like
d
orc
works as expected.But we have one important modification to the
replace
command:When exactly two selections of length 1 are present and they match according to
get_pair
, we will do replacement as a pair.Some [ ( ]text (here)[ ) ]
press
r{
Some [ { ]text (here)[ } ]
Note that this
replace
will happen whenever the selection matches the conditions, it could have been created withoutm
.What I intend to fix:
replace
should enforce that pairs will be balanced after. (this is mostly handled already if selection was made bym
)Condition for matching replace should be extended to selection pairs of
count_selections % 2 == 0
I know that there are a few more special cases to handle, but I want feedback on this idea before I move forward with it.
My WIP is working quite nicely I think, please give it a try