MCPcopy Create free account
hub / github.com/microsoft/vscode-extension-samples / activate

Function activate

getting-started-sample/src/extension.ts:8–31  ·  view source on GitHub ↗
(context: vscode.ExtensionContext)

Source from the content-addressed store, hash-verified

6// this method is called when your extension is activated
7// your extension is activated the very first time the command is executed
8export function activate(context: vscode.ExtensionContext): void {
9 context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.runCommand', async () => {
10 await new Promise(resolve => setTimeout(resolve, 1000));
11 vscode.commands.executeCommand('getting-started-sample.sayHello', vscode.Uri.joinPath(context.extensionUri, 'sample-folder'));
12 }));
13
14 context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.changeSetting', async () => {
15 await new Promise(resolve => setTimeout(resolve, 1000));
16 vscode.workspace.getConfiguration('getting-started-sample').update('sampleSetting', true);
17 }));
18
19 context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.setContext', async () => {
20 await new Promise(resolve => setTimeout(resolve, 1000));
21 vscode.commands.executeCommand('setContext', 'gettingStartedContextKey', true);
22 }));
23
24 context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.sayHello', () => {
25 vscode.window.showInformationMessage('Hello');
26 }));
27
28 context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.viewSources', () => {
29 return { openFolder: vscode.Uri.joinPath(context.extensionUri, 'src') };
30 }));
31}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected