-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathextension.ts
41 lines (33 loc) · 1.23 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import { commands, ExtensionContext, ProgressLocation, window } from 'vscode';
export function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand('extension.startTask', () => {
window.withProgress({
location: ProgressLocation.Notification,
title: "I am long running!",
cancellable: true
}, (progress, token) => {
token.onCancellationRequested(() => {
console.log("User canceled the long running operation");
});
progress.report({ increment: 0 });
setTimeout(() => {
progress.report({ increment: 10, message: "I am long running! - still going..." });
}, 1000);
setTimeout(() => {
progress.report({ increment: 40, message: "I am long running! - still going even more..." });
}, 2000);
setTimeout(() => {
progress.report({ increment: 50, message: "I am long running! - almost there..." });
}, 3000);
const p = new Promise<void>(resolve => {
setTimeout(() => {
resolve();
}, 5000);
});
return p;
});
}));
}