Vim icon indicating copy to clipboard operation
Vim copied to clipboard

`when clause contexts` can not be expected to work

Open jiahut opened this issue 4 years ago • 1 comments

Describe the bug Use the following configuration at the same time, in any case only the second configuration works

To Reproduce

Add the following configuration to settings.json

        "vim.leader": "<space>",
        {
            "before": [
                "leader",
                "o",
                "t"
            ],
            "commands": [
                "testing.runAtCursor",
            ],
            "when": "resourceExtname == .java"
        },
        {
            "before": [
                "leader",
                "o",
                "t"
            ],
            "commands": [
                "workbench.action.tasks.runTask",
            ],
        },

Expected behavior

The first task is executed by default, and the second task is enabled in the java file

Screenshots

when type <space> o t in a .java file, the console logs

[Extension Host] Remapper: debug: normalModeKeyBindingsMap. match found. before= ,o,t. after=undefined. command=workbench.action.tasks.runTask. remainingKeys=. mapDepth=1.
  • Extension (VsCodeVim) version: v1.21.7
  • VSCode version: 1.60.2
  • OS: win10

Additional context

None

jiahut avatar Sep 24 '21 07:09 jiahut

I think I have a similar issue, the when clause is not working with the same keybindings. Perhaps a bug?

In vim.normalModeKeyBindingsNonRecursive in settings I have:

 { "before": ["leader", "g", "n"], "commands": ["workbench.action.compareEditor.nextChange"], "when": ["textCompareEditorVisible && isInDiffEditor"],},
    { "before": ["leader", "g", "p"], "commands": ["workbench.action.compareEditor.previousChange"], "when": ["textCompareEditorVisible && isInDiffEditor"],},
    { "before": ["leader", "g", "n"], "commands": ["workbench.action.editor.nextChange"], "when": ["editorLangId == 'go'"]},
    { "before": ["leader", "g", "p"], "commands": ["workbench.action.editor.previousChange"], "when": ["editorTextFocus && vim.mode == 'Normal'"], },

The gn "nextChange" works everywhere it does not respect the when editorLangId == 'go', really what I wanted was when !isInDiffEditor for now as a work around I will change the keys.

rickswe avatar May 15 '24 02:05 rickswe