mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Add getting started sample
This commit is contained in:
27
getting-started-sample/src/extension.ts
Normal file
27
getting-started-sample/src/extension.ts
Normal file
@ -0,0 +1,27 @@
|
||||
// The module 'vscode' contains the VS Code extensibility API
|
||||
// Import the module and reference it with the alias vscode in your code below
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext): void {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.runCommand', async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
vscode.commands.executeCommand('getting-started-sample.sayHello', vscode.Uri.joinPath(context.extensionUri, 'sample-folder'));
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.changeSetting', async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
vscode.workspace.getConfiguration('getting-started-sample').update('sampleSetting', true);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.setContext', async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
vscode.commands.executeCommand('setContext', 'gettingStartedContextKey', true);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.sayHello', () => {
|
||||
vscode.window.showInformationMessage('Hello');
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user