-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Implemented new actions SelectWord
, SelectNextTextOccurrence
, SelectPreviousTextOccurrence
#3405
base: master
Are you sure you want to change the base?
Conversation
I am not sure if I am missing something but what's the difference between |
They are similar but "AltShiftLeft": "SelectWord|SelectPreviousTextOccurrence",
"AltShiftRight": "SelectWord|SelectNextTextOccurrence", micro-SelectTextOccurrence.webm |
I understand the purpose of adding But apart from that, Like for example if you duplicate/modify the "AltShiftLeft": "SelectWord&FindSelected&FindPrevious",
"AltShiftRight": "SelectWord&FindSelected&FindNext" Unless I am understanding wrong, I think what you really want is to have an action that selects a word ( |
Or maybe an option to not prompt you if there's a selection and another option not to jump to it. Should be pretty straightforward to do. I understand your use case but personally I am still not too sure about adding new actions ( TL;DR But of course, the ultimate decisions are on the maintainers and I am just giving my opinions. |
…Occurrence`, `SelectPreviousTextOccurrence`
cea1463
to
a9b098c
Compare
No question, I get the impression that you are trying to minimize code duplication at all costs. But IMHO it's not necessarily a bad thing to have a little duplicated code here and there. It really helps to decouple things from each other and increases readability by not adding extra conditions or wrappers. Finding the right balance is key. This can also be expressed in numbers: My implementation adds two actions with the cognitive complexity of 4 each (which is good), keeps the search entirely decoupled but adds a bit of code duplication. From my point of view the better deal. Please don't get me wrong. I greatly appreciate your commitment but I think your implementation has some serious flaws because of the mentioned reasons. |
One of my biggest concerns is the naming of the two. I would like to call them |
While it would be great to minimize code duplication, that was not my main concern. Nor the complexity or simplicity it adds. My concern was does it makes sense to add the actions you are proposing given the niche use case and other editors (I know of) use the search mechanism to achieve the same thing which was what I was suggesting. Would it make more sense to implement the All the suggestions I made were just trying to benefit a wider audience, not just your use case. They may not be perfect but would definitely be easier for people to utilize it for their own use case, just like yours, either with config json or lua script. |
It's actually one of my mini plugins, and I like it so much that I thought it might be of use to others as well. But if you really think it's bloatware and not a contribution, I don't mind not adding it. I really appreciate the work that has been done recently on |
I might be over-thinking this but I don't know, it just feels weird to me to have another find-like actions but more barebone. That being said...
yeah, you have a point and I agree with it. It doesn't hurt to add these actions in I think. It is good to have options as you said and pick & choose the ones you want.
Stealing vscode
or we can drop the
|
This PR adds 3 new actions:
SelectWord
Just selects the word the cursor is currently on.
If the character the cursor is currently on is not a word character or there is already a selection the actions returns
false
otherwisetrue
.The code doing this was already existing, just the according action was added.
SelectNextTextOccurrence
In case there is already a selection this actions searches for the next text occurrence of the selected text and changes the selection to this location. In case there is no selection or there are multiple cursors this actions returns
false
.SelectPreviousTextOccurrence
Same as for
SelectNextTextOccurrence
So the following keybinding selects the word you might be on with the first press, the second press selects the next / previous text occurrence.
Here the first press selects word (in case there is not selection already) and immediately selects the next / prev occurrence.
There is one issue with the current implementation.
The original behavior of
h.Cursor.SelectWord()
extended the selection by one character to the right in case the cursor was not on a word character.To embrace the power of chaining this was changed to just return in this case. But maybe there is a deeper thought behind this.