DCsunset / vscode-modal-editor

Customizable extension to turn VS Code into a modal editor
GNU Affero General Public License v3.0
36 stars 4 forks source link

Cursor selection status creates confusing interactions #8

Open bhainesva opened 1 year ago

bhainesva commented 1 year ago

Hello,

I'm finding that the behavior of trying to treat the character "under" the block cursor as "selected" without actually selecting it leads to some confusing interactions, a couple in particular I've run into with editor.action.addSelectionToNextFindMatch. In general, it also makes it confusing to interact with other vscode features/extensions that care about selected text.

For example if I wanted to change "old" in this text to "new" ( | represents cursor ):

"|old"
"old"

In insert mode I would do ⌘-d ⌘-d n e w, but from normal mode, ⌘-d ⌘-d modalEditor.cut produces:

"|
"|

This can be accommodated with a command like "w" as defined in the preset that ends with "cursorLeftSelect". w ⌘-d modalEditor.cut works as expected (though non-modalEditor commands such as editor.action.transformToUppercase don't work).

However, if you instead start with your cursor after the 'd' of the first 'old' and try b ⌘-d modalEditor.cut you get:

"|"
"|

I suspect vscode internally thinking of the cursor existing between characters means there's not a simple solution, but figured I'd ask just in case.

DCsunset commented 1 year ago

I don't quite understand the problem you are facing here and what you want to achieve. The keybinding for ⌘-d is not handled by modalEditor and I'm not sure what you bind it to. In helix, it should be bound to modalEditor.delete right?

bhainesva commented 1 year ago

Ah sorry that wasn't clear, ⌘-d is a binding for editor.action.addSelectionToNextFindMatch.

DCsunset commented 1 year ago

I see. It's indeed a problem as commands provided by VSCode assume that the range doesn't include the current cursor. There seems to be no perfect solution to that.

For such cases, I usually patch the original command by appending an extra command to move it on char left using modalEditor.executeCommand.