@@ -80,6 +80,66 @@ function editComparer(leftOperand: ScriptRegion, rightOperand: ScriptRegion): nu
80
80
}
81
81
}
82
82
83
+ class AnimatedStatuBarItem {
84
+ private statusBarItem : vscode . StatusBarItem ;
85
+ private maxCount : number ;
86
+ private counter : number ;
87
+ private baseText : string ;
88
+ private text : string ;
89
+ private timerInterval : number ;
90
+ private ticks : number ;
91
+ private intervalId : NodeJS . Timer ;
92
+
93
+ constructor ( ) {
94
+ this . statusBarItem = Window . createStatusBarItem ( ) ;
95
+ this . baseText = "formatting" ;
96
+ this . maxCount = 4 ;
97
+ this . counter = 0 ;
98
+ this . timerInterval = 300 ;
99
+ this . ticks = 0 ;
100
+ }
101
+
102
+ updateCounter ( ) {
103
+ this . counter = ( this . counter + 1 ) % this . maxCount ;
104
+ this . ticks = this . ticks + 1 ;
105
+ }
106
+
107
+ updateText ( ) {
108
+ this . text = this . baseText + "." . repeat ( this . counter ) + " " . repeat ( this . maxCount - this . counter - 1 ) ;
109
+ }
110
+
111
+ update ( ) {
112
+ this . updateCounter ( ) ;
113
+ this . updateText ( ) ;
114
+ this . statusBarItem . text = this . text ;
115
+ }
116
+
117
+ reset ( ) {
118
+ this . counter = 0 ;
119
+ }
120
+
121
+ start ( hideWhenDone ?: Thenable < any > ) {
122
+ this . intervalId = setInterval ( ( ) => this . update ( ) , this . timerInterval ) ;
123
+ this . show ( ) ;
124
+ if ( hideWhenDone !== undefined ) {
125
+ hideWhenDone . then ( ( ) => this . stop ( ) ) ;
126
+ }
127
+ }
128
+
129
+ stop ( ) {
130
+ clearInterval ( this . intervalId ) ;
131
+ this . hide ( ) ;
132
+ }
133
+
134
+ show ( ) {
135
+ this . statusBarItem . show ( ) ;
136
+ }
137
+
138
+ hide ( ) {
139
+ this . statusBarItem . hide ( ) ;
140
+ }
141
+ }
142
+
83
143
class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider , DocumentRangeFormattingEditProvider {
84
144
private languageClient : LanguageClient ;
85
145
@@ -110,8 +170,10 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
110
170
range : Range ,
111
171
options : FormattingOptions ,
112
172
token : CancellationToken ) : TextEdit [ ] | Thenable < TextEdit [ ] > {
113
- let textEdits = this . executeRulesInOrder ( document , range , options , 0 ) ;
114
- Window . setStatusBarMessage ( "formatting..." , textEdits ) ;
173
+
174
+ let status : AnimatedStatuBarItem = new AnimatedStatuBarItem ( ) ;
175
+ let textEdits : Thenable < TextEdit [ ] > = this . executeRulesInOrder ( document , range , options , 0 ) ;
176
+ status . start ( textEdits ) ;
115
177
return textEdits ;
116
178
}
117
179
@@ -174,7 +236,7 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
174
236
return this . executeRulesInOrder ( document , range , options , index + 1 ) ;
175
237
} ) ;
176
238
} else {
177
- return Promise . resolve ( new TextEdit [ 0 ] ) ;
239
+ return Promise . resolve ( TextEdit [ 0 ] ) ;
178
240
}
179
241
}
180
242
0 commit comments