Skip to main content

commandsModule

MS Code Extension API


MS Code Extension API / core/extensionAPI/modules/commandsModule

core/extensionAPI/modules/commandsModule

Type Aliases

CommandsModule

CommandsModule = ReturnType<typeof createCommandsModule>

Defined in: core/extensionAPI/modules/commandsModule.ts:34

Functions

createCommandsModule()

createCommandsModule(_extId): object

Defined in: core/extensionAPI/modules/commandsModule.ts:9

Parameters

_extId

string

Returns

executeCommand

executeCommand: (id, ...args) => Promise<any>

Programmatically execute a registered command.

Parameters
id

string

args

...any[]

Returns

Promise<any>

Example
await mscode.commands.executeCommand('editor.action.formatDocument');
registerCommand

registerCommand: (id, handler) => IDisposable

Register a new command. Returns a disposable — call .dispose() in deactivate() to unregister.

Parameters
id

string

handler

(...args) => any

Returns

IDisposable

Example
const disposable = mscode.commands.registerCommand('myExt.helloWorld', () => {
mscode.window.showInformationMessage('Hello World!');
});