@@ -11,13 +11,15 @@ export function setAnimatedStatusBarMessage(text: string, hideWhenDone: Thenable
11
11
}
12
12
13
13
class AnimatedStatuBarItem implements StatusBarItem {
14
+ private readonly animationRate : number ;
14
15
private statusBarItem : StatusBarItem ;
15
16
private maxCount : number ;
16
17
private counter : number ;
17
18
private baseText : string ;
18
19
private timerInterval : number ;
19
- private ticks : number ;
20
+ private elapsedTime : number ;
20
21
private intervalId : NodeJS . Timer ;
22
+ private suffixStates : string [ ] ;
21
23
22
24
get alignment ( ) : StatusBarAlignment {
23
25
return this . statusBarItem . alignment ;
@@ -60,12 +62,14 @@ class AnimatedStatuBarItem implements StatusBarItem {
60
62
}
61
63
62
64
constructor ( baseText : string , alignment ?: StatusBarAlignment , priority ?: number ) {
65
+ this . animationRate = 1 ;
63
66
this . statusBarItem = window . createStatusBarItem ( alignment , priority ) ;
64
67
this . baseText = baseText ;
65
- this . maxCount = 4 ;
66
68
this . counter = 0 ;
67
- this . timerInterval = 300 ;
68
- this . ticks = 0 ;
69
+ this . suffixStates = [ " " , ". " , ".. " , "..." ] ;
70
+ this . maxCount = this . suffixStates . length ;
71
+ this . timerInterval = ( ( 1 / this . maxCount ) * 1000 ) / this . animationRate ;
72
+ this . elapsedTime = 0 ;
69
73
}
70
74
71
75
show ( hideWhenDone ?: Thenable < any > ) : void {
@@ -87,11 +91,11 @@ class AnimatedStatuBarItem implements StatusBarItem {
87
91
88
92
_updateCounter ( ) : void {
89
93
this . counter = ( this . counter + 1 ) % this . maxCount ;
90
- this . ticks = this . ticks + 1 ;
94
+ this . elapsedTime = this . elapsedTime + this . timerInterval ;
91
95
}
92
96
93
97
_updateText ( ) : void {
94
- this . text = this . baseText + "." . repeat ( this . counter ) + " " . repeat ( this . maxCount - this . counter - 1 ) ;
98
+ this . text = this . baseText + this . suffixStates [ this . counter ] ;
95
99
}
96
100
97
101
_update ( ) : void {
0 commit comments