@@ -5,7 +5,7 @@ import { Progress, ProgressLocation, window } from 'vscode';
5
5
import { Disposable , LanguageClient } from 'vscode-languageclient' ;
6
6
import { createDeferred , Deferred } from '../../utils/async' ;
7
7
8
- export class ProgressReporting {
8
+ export class ProgressReporting implements Disposable {
9
9
private statusBarMessage : Disposable | undefined ;
10
10
private progress : Progress < { message ?: string ; increment ?: number } > | undefined ;
11
11
private progressDeferred : Deferred < void > | undefined ;
@@ -19,6 +19,7 @@ export class ProgressReporting {
19
19
} ) ;
20
20
21
21
this . languageClient . onNotification ( 'python/beginProgress' , async _ => {
22
+ this . clearProgress ( ) ;
22
23
this . progressDeferred = createDeferred < void > ( ) ;
23
24
window . withProgress ( {
24
25
location : ProgressLocation . Window ,
@@ -36,11 +37,17 @@ export class ProgressReporting {
36
37
this . progress . report ( { message : m } ) ;
37
38
} ) ;
38
39
39
- this . languageClient . onNotification ( 'python/endProgress' , _ => {
40
- if ( this . progressDeferred ) {
41
- this . progressDeferred . resolve ( ) ;
42
- this . progressDeferred = undefined ;
43
- }
44
- } ) ;
40
+ this . languageClient . onNotification ( 'python/endProgress' , _ => this . clearProgress ( ) ) ;
41
+ }
42
+
43
+ public dispose ( ) : void {
44
+ this . clearProgress ( ) ;
45
+ }
46
+
47
+ private clearProgress ( ) : void {
48
+ if ( this . progressDeferred ) {
49
+ this . progressDeferred . resolve ( ) ;
50
+ this . progressDeferred = undefined ;
51
+ }
45
52
}
46
53
}
0 commit comments