-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add option textfiltermode=keep-selection #3974
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
base: master
Are you sure you want to change the base?
Add option textfiltermode=keep-selection #3974
Conversation
Andriamanitra
left a comment
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.
I think this should be the default behavior. Losing the selection always felt more like a bug than an intentional design choice. Maybe we don't even need the setting?
The implementation seems reasonable to me. I tested it a bit and everything seemed to work alright. There is a bug that causes selections to get messed up when undoing multicursor edits (including the ones done with textfilter), but it already existed before these changes.
I'm on the fence about whether or not it should select the text when you do textfilter without having a selection. On one hand it's nice to see exactly what was inserted but it feels a bit weird for the inserted text to be selected by default.
|
@Andriamanitra I think that was really good feedback. See new commit where we instead have the options:
I also made What do you think? |
|
Well done. @dmaluka |
|
I'm inclined to think we should just make it unconditional. Then if anyone complains about the changed behavior, we can always introduce an option (so that we know there is actually a need for introducing it). |
Me too. @hemmingsv |
Yes! Less moving parts sounds good. In this case I suppose no documentation changes are needed? Will push the updated code on Monday. |
Background:
The
textfiltercommand is great for running a single shell command on a selection (or multiple) from the buffer as stdin. The selection is replaced by the command output, but the output is not selected afterward.Expected changes:
textfiltermode=keep-selectionto keep the output selected. This is great for chaining commands and in line with what I would expect textfilter to do.textfiltermode=drop-selection)Personal note: I am new to the code base and never written Go. I find the repo very easy to work with. I might have implemented this in a completely stupid way though. Harsh feedback is welcome. I could have made this into a plugin, but I found it hard to implement the textfilter command in Lua, so went with this native approach instead. If this approach is approved, then I will oversee the documentation as well.