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

Search single character #4

Closed suhr closed 4 years ago

suhr commented 4 years ago

Sometimes you just want to jump to the next comma.

suhr commented 4 years ago

It finds out, I didn't read the README.md careful again. Anyway, the following command doesn't work:

"s": [
    {
        "command": "modaledit.search",
        "args": {
            "acceptAfter": 1
        }
    },
    { "command": "cancelSelection" }
]
johtela commented 4 years ago

So, you want to clear selection after the cursor has jumped to the searched character?

The problem is that "cancelSelection" is run right after search mode is activated, and before you press the searched character. That messes up the search mode somehow.

Even if it did not do that, the effect would still not be what you expect. The problem remains that selection is cleared too soon. The easiest fix would be to add a new flag to "modaledit.search" command to clear selection after search is accepted. I'll think about this and see if there is a more general way to do the same thing.

suhr commented 4 years ago

By the way, for some reason character search switches me to the normal mode, even when I start search in the input mode (using Alt+s keybinding).

johtela commented 4 years ago

Ok. That is a bug. I'll fix that one.

johtela commented 4 years ago

In version 1.3 search returns to insert mode, if it was invoked from there. Also fixed few other issues that occurred with the search when it was run through VS Code's standard key bindings.

See also the new typeAfterAccept argument to modaledit.search command. It allows you to run commands (through key bindings) after search is accepted. For example, assuming that s is bound to modaledit.toggleSelection command, you can clear the selection after search like this:

    {
       "command": "modaledit.search",
        "args": {
            "acceptAfter": 1,
            "typeAfterAccept": "s"
        }
    }