@@ -129,7 +129,7 @@ function makeRlsProcess(): Promise<child_process.ChildProcess> {
129
129
} ) ;
130
130
131
131
return childProcessPromise . catch ( ( ) => {
132
- window . setStatusBarMessage ( 'RLS could not be started' ) ;
132
+ stopSpinner ( 'RLS could not be started' ) ;
133
133
return Promise . reject ( undefined ) ;
134
134
} ) ;
135
135
}
@@ -151,7 +151,7 @@ function startLanguageClient(context: ExtensionContext)
151
151
}
152
152
warnOnMissingCargoToml ( ) ;
153
153
154
- window . setStatusBarMessage ( 'RLS: starting up ' ) ;
154
+ startSpinner ( 'RLS starting' ) ;
155
155
156
156
warnOnRlsToml ( ) ;
157
157
// Check for deprecated env vars.
@@ -172,7 +172,7 @@ function startLanguageClient(context: ExtensionContext)
172
172
// Create the language client and start the client.
173
173
lc = new LanguageClient ( 'Rust Language Server' , serverOptions , clientOptions ) ;
174
174
175
- diagnosticCounter ( ) ;
175
+ progressCounter ( ) ;
176
176
177
177
const disposable = lc . start ( ) ;
178
178
context . subscriptions . push ( disposable ) ;
@@ -207,17 +207,40 @@ async function autoUpdate() {
207
207
}
208
208
}
209
209
210
- function diagnosticCounter ( ) {
210
+ function progressCounter ( ) {
211
+ const runningProgress : { [ index : string ] : boolean } = { } ;
212
+ const asPercent = ( fraction : number ) : string => `${ Math . round ( fraction * 100 ) } %` ;
211
213
let runningDiagnostics = 0 ;
212
214
lc . onReady ( ) . then ( ( ) => {
213
- lc . onNotification ( new NotificationType ( 'rustDocument/beginBuild' ) , function ( _f : any ) {
215
+
216
+ stopSpinner ( 'RLS' ) ;
217
+
218
+ lc . onNotification ( new NotificationType ( 'window/progress' ) , function ( progress : any ) {
219
+ if ( progress . done ) {
220
+ delete runningProgress [ progress . id ] ;
221
+ } else {
222
+ runningProgress [ progress . id ] = true ;
223
+ }
224
+ if ( Object . keys ( runningProgress ) . length ) {
225
+ const msg =
226
+ typeof progress . percentage === 'number' ? asPercent ( progress . percentage ) :
227
+ progress . message ? progress . message : '' ;
228
+ startSpinner ( `RLS ${ msg } ` ) ;
229
+ } else {
230
+ stopSpinner ( 'RLS' ) ;
231
+ }
232
+ } ) ;
233
+
234
+ // FIXME these are legacy notifications used by RLS ca jan 2018.
235
+ // remove once we're certain we've progress on.
236
+ lc . onNotification ( new NotificationType ( 'rustDocument/beginBuild' ) , function ( _f : any ) {
214
237
runningDiagnostics ++ ;
215
- startSpinner ( 'RLS: working' ) ;
238
+ startSpinner ( 'RLS' , ' working') ;
216
239
} ) ;
217
- lc . onNotification ( new NotificationType ( 'rustDocument/diagnosticsEnd' ) , function ( _f : any ) {
240
+ lc . onNotification ( new NotificationType ( 'rustDocument/diagnosticsEnd' ) , function ( _f : any ) {
218
241
runningDiagnostics -- ;
219
242
if ( runningDiagnostics <= 0 ) {
220
- stopSpinner ( 'RLS: done ' ) ;
243
+ stopSpinner ( 'RLS' ) ;
221
244
}
222
245
} ) ;
223
246
} ) ;
0 commit comments