forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogressService.ts
More file actions
32 lines (26 loc) · 904 Bytes
/
Copy pathprogressService.ts
File metadata and controls
32 lines (26 loc) · 904 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { ProgressOptions } from 'vscode';
import { Deferred, createDeferred } from '../utils/async';
import { IApplicationShell } from './types';
export class ProgressService {
private deferred: Deferred<void> | undefined;
constructor(private readonly shell: IApplicationShell) {}
public showProgress(options: ProgressOptions): void {
if (!this.deferred) {
this.createProgress(options);
}
}
public hideProgress(): void {
if (this.deferred) {
this.deferred.resolve();
this.deferred = undefined;
}
}
private createProgress(options: ProgressOptions) {
this.shell.withProgress(options, () => {
this.deferred = createDeferred();
return this.deferred.promise;
});
}
}