Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace commands

Index

Functions

  • executeCommand<T>(commandId: string, ...args: any[]): Thenable<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 Thenable<T | undefined>

  • getCommands(filterInternal?: boolean): Thenable<string[]>
  • Retrieve the list of all available commands. Commands starting an underscore are treated as internal commands.

    Parameters

    • Optional filterInternal: boolean

      Set true to not see internal commands (starting with an underscore)

    Returns Thenable<string[]>

    Thenable that resolves to a list of command ids.

  • Register the given command and handler if present.

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

    Parameters

    • command: string | CommandDescription
    • Optional handler: ((...args: any[]) => any)
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional thisArg: any

    Returns Disposable

  • registerDiffInformationCommand(command: string, callback: ((diff: LineChange[], ...args: any[]) => any), thisArg?: any): Disposable
  • Registers a diff information command that can be invoked via a keyboard shortcut, a menu item, an action, or directly.

    Diff information commands are different from ordinary commands as they only execute when there is an active diff editor when the command is called, and the diff information has been computed. Also, the command handler of an editor command has access to the diff information.

    Parameters

    • command: string

      A unique identifier for the command.

    • callback: ((diff: LineChange[], ...args: any[]) => any)

      A command handler function with access to the diff information.

    • Optional thisArg: any

      The this context used when invoking the handler function.

    Returns Disposable

    Disposable which unregisters this command on disposal.

  • registerHandler(commandId: string, handler: ((...args: any[]) => any), thisArg?: any): Disposable
  • Register the given handler for the given command identifier.

    Parameters

    • commandId: string

      a given command id

    • handler: ((...args: any[]) => any)

      a command handler

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

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

          • Rest ...args: any[]

          Returns any

    • Optional thisArg: any

    Returns Disposable

  • Registers a text editor command that can be invoked via a keyboard shortcut, a menu item, an action, or directly.

    Text editor commands are different from ordinary commands as they only execute when there is an active editor when the command is called. Also, the command handler of an editor command has access to the active editor and to an edit-builder.

    Parameters

    • command: string

      A unique identifier for the command.

    • callback: ((textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void)

      A command handler function with access to an editor and an edit.

    • Optional thisArg: any

      The this context used when invoking the handler function.

    Returns Disposable

    Disposable which unregisters this command on disposal.