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

Function activate

progress-sample/src/extension.ts:7–41  ·  view source on GitHub ↗
(context: ExtensionContext)

Source from the content-addressed store, hash-verified

5import { commands, ExtensionContext, ProgressLocation, window } from 'vscode';
6
7export function activate(context: ExtensionContext) {
8 context.subscriptions.push(commands.registerCommand('extension.startTask', () => {
9 window.withProgress({
10 location: ProgressLocation.Notification,
11 title: "I am long running!",
12 cancellable: true
13 }, (progress, token) => {
14 token.onCancellationRequested(() => {
15 console.log("User canceled the long running operation");
16 });
17
18 progress.report({ increment: 0 });
19
20 setTimeout(() => {
21 progress.report({ increment: 10, message: "I am long running! - still going..." });
22 }, 1000);
23
24 setTimeout(() => {
25 progress.report({ increment: 40, message: "I am long running! - still going even more..." });
26 }, 2000);
27
28 setTimeout(() => {
29 progress.report({ increment: 50, message: "I am long running! - almost there..." });
30 }, 3000);
31
32 const p = new Promise<void>(resolve => {
33 setTimeout(() => {
34 resolve();
35 }, 5000);
36 });
37
38 return p;
39 });
40 }));
41}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected