Options
All
  • Public
  • Public/Protected
  • All
Menu

Module commands

Namespace for dealing with commands. In short, a command is a function with a unique identifier. The function is sometimes also called command handler.

Commands can be added using the registerCommand and registerTextEditorCommand functions. Registration can be split in two step: first register command without handler, second register handler by command id.

Any contributed command are available to any plugin, command can be invoked by executeCommand function.

Simple example that register command:

theia.commands.registerCommand({id:'say.hello.command'}, ()=>{
    console.log("Hello World!");
});

Simple example that invoke command:

theia.commands.executeCommand('core.about');

Index

Functions

executeCommand

  • executeCommand<T>(commandId: string, ...args: any[]): PromiseLike<T | undefined>
  • Execute the active handler for the given command and arguments.

    Reject if a command cannot be executed.

    Type parameters

    • T

    Parameters

    • commandId: string
    • Rest ...args: any[]

    Returns PromiseLike<T | undefined>

registerCommand

  • Register the given command and handler if present.

    Throw if a command is already registered for the given command identifier.

    Parameters

    • command: Command
    • Optional handler: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns Disposable

registerHandler

  • registerHandler(commandId: string, handler: function): Disposable
  • Register the given handler for the given command identifier.

    Parameters

    • commandId: string

      a given command id

    • handler: function

      a command handler

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns Disposable

registerTextEditorCommand

  • Register a text editor command which can execute only if active editor present and command has access to the active editor

    Parameters

    Returns Disposable