Command based configuration items

Both enum and command configuration items are configured with a reference to something in the CommandsRegistry. I have two questions:

  1. These don’t seem to work at all in global extension preference. There isn’t a logical Workspace context, which is fine if your command doesn’t depend on one. But I can’t find any evidence of the command being invoked at all. Is this something expected to work currently? An example?
  2. I hadn’t thought of commands in the CommandsRegistry as returning a value, but it makes sense in this context. Maybe this is a basic JavaScript question…is there a way to make this work by returning a promise, or returning a value by callback?

Yes, this is currently expected. Command-related configurations are not supported for the global configuration, as all extension code is workspace-specific (all extension code is executed within a JavaScript sandbox related to the project in which it’s instanced). Since global configuration has no “project”, there is no extension instance running in JavaScript that could serve command items. We could consider facilitating this at some point in the future, but that’s what’s currently up here!

For enum types and their resolve value, I believe Promises are fully supported. The runtime will wait for the promise to resolve. I can make a note to update our documentation on this to be more clear that you can use promises.

I think this also goes for the normal command value of command types.

1 Like