Closed digitalmaster closed 4 months ago
Oh nvm looks like this is intentional: https://github.com/DCsunset/vscode-modal-editor/blob/c3a4469fd8fcc788ffb112e9ae96b168606ee332/src/commands.ts#L175-L177
The use case is I want to issue a visual selection command and then perform an wrapping insert action (ie., wrapping selection with brackets).
I've tested that removing this line does the trick for me on my build. I'm curious what the use case for clearing the selection is tho? 🤔
We could make it a setting (defaulting to current behavior)?
Yes that was intentional originally. Because any insertion under active selection in VSCode will replace the selection with the inserted text.
But it does make sense to let the user decide whether to clear to selection. I'll add a setting shortly to address this issue..
Gotcha. Makes sense.
Because any insertion under active selection in VSCode will replace the selection with the inserted text.
This is true. However, replacement only happens once you've started typing characters not on the action to go back to insert mode (since that's not a thing).
I wonder if the default behavior should be to not clear selection? For reference, ModalEdit also doesn't clear it for the same reason.
Yes. I think I can probably remove the clearSelections
command. Users can call it by themselves if they want.
This has been implemented in the latest commit with setMode
. (Note: setInsertMode
still clears selections for backward compatibility)
Feel free to try it if you have time.
Nice!.
Just pulled/built your changes. However your backwards compatibility change essentially makes it so that I can't use "modalEditor.setInsertMode".. So trying to figure how to use "modalEditor.setMode("insert")".. Currently getting the following error:
command 'modalEditor.setMode('insert')' not found
Edit: I think it's probably better to just make this a setting that defaults to current behavior for backwards compatibility. I think having this subtle difference in APIs is bound to cause confusion.
You should pass arguments using args
in ComplexCommand instead of putting it in the command name
Ahh.. makes sense. Thanks 🙌🏽🙌🏽
Yea, that did the trick for me. I essentially just created a small object with the search change into insert mode using the right helper:
const Mode = {
Insert: { command: "modalEditor.setMode", args: "insert" }
};
Gonna go ahead and close this issue for now. Still think having two different behaviors for these commands will create confusion for others. Adding a setting that defaults to on to main backward compatibility seems like the better way to do this.
Thanks again for iterating on this so quickly. I've officially migrated over to using this plugin 🎉
For some reason anytime I toggle insert mode it clears the current selection. Is there a way to prevent that?