johtela / vscode-modaledit

Configurable Modal Editing in VS Code
https://johtela.github.io/vscode-modaledit/docs/README.html
Other
89 stars 8 forks source link

New commands: reset and enable selection #16

Closed haberdashPI closed 3 years ago

haberdashPI commented 4 years ago

Hi there! Thanks again for your great extension.

I have been using your new updates on master and noticed that you are missing two small features that are useful when I am working with multiple cursors and various selection related tasks in my own configuration of modaledit.

The problem these are trying to solve is that, in many cases, you don't want switching between selection modes to remove multiple cursors, which the current version doesn't allow for.

This adds two small commands:

There may also be a use for disableSelection which would call resetSelection and change the selection mode to off, but in my current configuration I haven't had a need for it.

I'm not sold on the exact names for these commands. I could see a number of other options.

This again has some changes to whitespace that VSCode automatically does for me, which I've tried to separate out in case you don't want that.

haberdashPI commented 4 years ago

Whoops, looks like there is a draft of my old pr response in here. Sorry about that. I'll clean that out...

johtela commented 3 years ago

Hi,

Sorry that this took so long again. I started to merge your changes, but then noticed a contradiction between the code and the documentation. The intention was that resetSelection stays in the selection mode? In the code the functions sets the selecting flag to false which jumps back to normal mode. I tested it to make sure that it does.

If the intention is to remain in the selection mode, then you should not reset the flag. On the other hand, if the selecting flag is not touched, there is no need to call the updateCursorAndStatusBar function either. In fact, then this command could be just general VS Code command because it is not require ModalEdit at all. So, in that sense I don't know if it belongs to the extension at all.

enableSelection command is fine, and can be added as-is.

haberdashPI commented 3 years ago

Whoops! Good point about reset selection. I had been going back and forth about how to set it up; I think it makes the most sense to update the documentation to reflect the actual behavior.

It has occurred to me that a possible alternative, more "orthogonal" solution could be to create a simpler command that just sets the selection flag to false and updates the status bar, but this doesn't seem very useful without first changing the selection (and makes less sense with the way you have user selections "count" as moving into selection mode).

johtela commented 3 years ago

These commands are now merged to master, and will be released in version 2.1. I took the liberty of renaming resetSelection to cancelMultipleSelections because essentially it cancels the selection mode, but preserves multiple cursors. It is a lengthy name, but I think is less ambiguous.

haberdashPI commented 3 years ago

Great! Thanks for merging this! I like the new name you picked, it seems better to me.