Configuration command type does not work?

I was trying to set use the “command” type of configuration, and I found that while my command works fine from the command palette, in the extension settings panel it creates the button, but pushing the button appears to do nothing at all except leave a spinning progress indicator.

Here’s the snippets from my extension.json:

In the “commands” entry I have this which works fine:

    "command-palette": [
      {
        "title": "Detect Dub",
        "command": "dvelop.detectDub"
      }
    ]

In the “config” section I have this:

        {
          "key": "dvelop.detectDub",
          "title": "Detect Dub",
          "description": "Locate dub automatically",
          "type": "command",
          "command": "dvelop.detectDub"
        }

Am I doing something wrong? I looked around and I couldn’t find any extensions using the command type. (Context here is that I want this to fire off a command that uses /usr/bin/which to find the appropriate path for a helper program, and update another configuration item. Again, this works perfectly from the palette just not the config UI.)

Update: it looks like it works correctly if I do this from the project UI, but that’s not the “right” place, for this, as the setting is global.

I believe this is an oversight in both our docs and the API: Command configuration types are not supported in the global scope, as they require invoking code in the extension. Since extensions are executing per-workspace, there is no “global” code for this to be possible. If you have no workspace windows open, your extension will not be running.

This might be something that is possible in the future, perhaps if we approach a method of having global, shared code in some way similar to Shared Web Workers. For the time being I’ll make a note for us to update the documentation, as well as likely disable this configuration type in the global context from showing.

1 Like

It would be useful to be able to do this, but not super urgent.