Your search found these items:
Your search did not match any articles.
CommandsRegistry class is used to register and invoke extension commands. A shared instance of the class is always available as the
nova.commands environment property.
register(name, callable, [thisValue])
Registers a command with the registry, making it available for binding to command palette and menu items declared in the extension’s
If the command should be user-visible, the
name argument should match a command declared in the extension manifest.
callable will be invoked with a different first argument depending on the category / context in which the command is defined:
- Commands that are present in the Editor menu (using the
editorcommands category) will receive the focused TextEditor object
- Commands appearing in all other categories will receive the current Workspace object
- Commands that are not defined in the manifest will receive the current Workspace object
thisValue argument may be used to set what
this is bound to when the callable is invoked. If omitted,
this will be
This method returns a Disposable that can be used to unregister the command.
Invokes the command registered for a given name, if any.
The command’s callback will be invoked as if the user had chosen it from the Extensions menu (or command palette).
The first argument the command’s callback receives will be the current Workspace. Additional arguments provided to this method will be delivered to the command after this workspace argument.
Note: For commands that appear in the editor menu, this can cause a different first object to be delivered, as those commands typically expect a TextEditor object. Commands can test the type of their first argument using the TextEditor.isTextEditor() class method.
This method returns a
Promise object that resolves to the result of invoking the command. If no command is registered for the name, the promise will be rejected with an error.