ryuta46 / vscode-multi-command

Visual Studio Code Plugin named multi-command
MIT License
229 stars 14 forks source link

Doubts in the use of "when" with "resourceDirname" #79

Closed JLLMNCHR closed 1 year ago

JLLMNCHR commented 1 year ago

This example is the base of something more complex that I need to implement.

But for that, I need to understand exactly how "when" based on "resourceDirname" works.

I am probably wrong, but it seems to me that "when" based on "resourceDirname" is not working as it should with this extension.

The thing is, I want the execution to fire and print " ** IT WORKS! **" in the terminal when I save the 'Test.txt' file (located at 'C:/VSCODE_PROJECTS/SFES/sfeaapp').

When I use "resourceFilename" it works correctly, but with "resourceDirname" I can't get it to work.

[
    {
        "key": "ctrl+s",
        "command": "extension.multiCommand.execute",
        "args": {
            "interval": 1000,
            "sequence": [
                {
                    "command": "workbench.action.files.save"
                },
                {
                    "command": "workbench.action.terminal.sendSequence",
                    "args": {
                        "text": " ****************** IT WORKS! ******************"
                    }
                }
            ]
        },
        //"when": "resourceDirname == C:/VSCODE_PROJECTS/SFES/sfeaapp" //DOESNT WORKS
        //"when": "resourceDirname == C:\\VSCODE_PROJECTS\\SFES\\sfeaapp" //DOESNT WORKS
        //"when": "resourceFilename == Test.txt" //IT WORKS
    }
]

Anny help will be appreciated.

JLLMNCHR commented 1 year ago

Sorry, with this kind of "advanced inspection" I have realized that the root directory in my Windows is interpreted as 'c', not 'C'.

So the proper line is:

"when": "resourceDirname == c:\\CODIGO\\VSCODE_PROJECTS\\TIREA\\SFES\\SFEAAPP\\sfeaapp"

To find all possible context keys:

  1. Run the Developer: Toggle Developer Tools vscode command
  2. Then run the Developer: Inspect Context Keys vscode command and then click anywhere
  3. Expand the context object in the console, and you should see a full list of context key-value pairs

image image image

ryuta46 commented 1 year ago

This multi-command extension does not resolve when context. when clause context in keybindings.json is core function in vscode.

Please refer the document of vscode and open an issue in vscode github if you have a question about the function. https://code.visualstudio.com/api/references/when-clause-contexts