@@ -127,7 +127,7 @@ function makeRlsProcess(): Promise<child_process.ChildProcess> {
127
127
} ) ;
128
128
129
129
return childProcessPromise . catch ( ( ) => {
130
- window . setStatusBarMessage ( 'RLS could not be started' ) ;
130
+ stopSpinner ( 'RLS could not be started' ) ;
131
131
return Promise . reject ( undefined ) ;
132
132
} ) ;
133
133
}
@@ -149,7 +149,7 @@ function startLanguageClient(context: ExtensionContext)
149
149
}
150
150
warnOnMissingCargoToml ( ) ;
151
151
152
- window . setStatusBarMessage ( 'RLS: starting up ' ) ;
152
+ startSpinner ( 'RLS starting' ) ;
153
153
154
154
warnOnRlsToml ( ) ;
155
155
// Check for deprecated env vars.
@@ -170,7 +170,7 @@ function startLanguageClient(context: ExtensionContext)
170
170
// Create the language client and start the client.
171
171
lc = new LanguageClient ( 'Rust Language Server' , serverOptions , clientOptions ) ;
172
172
173
- diagnosticCounter ( ) ;
173
+ progressCounter ( ) ;
174
174
175
175
const disposable = lc . start ( ) ;
176
176
context . subscriptions . push ( disposable ) ;
@@ -205,17 +205,26 @@ async function autoUpdate() {
205
205
}
206
206
}
207
207
208
- function diagnosticCounter ( ) {
209
- let runningDiagnostics = 0 ;
208
+ function progressCounter ( ) {
209
+ const runningProgress : { [ index : string ] : boolean } = { } ;
210
+ const asPercent = ( fraction : number ) : string => `${ Math . round ( fraction * 100 ) } %` ;
210
211
lc . onReady ( ) . then ( ( ) => {
211
- lc . onNotification ( new NotificationType ( 'rustDocument/beginBuild' ) , function ( _f : any ) {
212
- runningDiagnostics ++ ;
213
- startSpinner ( 'RLS: working' ) ;
214
- } ) ;
215
- lc . onNotification ( new NotificationType ( 'rustDocument/diagnosticsEnd' ) , function ( _f : any ) {
216
- runningDiagnostics -- ;
217
- if ( runningDiagnostics <= 0 ) {
218
- stopSpinner ( 'RLS: done' ) ;
212
+
213
+ stopSpinner ( 'RLS' ) ;
214
+
215
+ lc . onNotification ( new NotificationType ( 'window/progress' ) , function ( progress : any ) {
216
+ if ( progress . done ) {
217
+ delete runningProgress [ progress . id ] ;
218
+ } else {
219
+ runningProgress [ progress . id ] = true ;
220
+ }
221
+ if ( Object . keys ( runningProgress ) . length ) {
222
+ const msg =
223
+ typeof progress . percentage === 'number' ? asPercent ( progress . percentage ) :
224
+ progress . message ? progress . message : '' ;
225
+ startSpinner ( `RLS ${ msg } ` ) ;
226
+ } else {
227
+ stopSpinner ( 'RLS' ) ;
219
228
}
220
229
} ) ;
221
230
} ) ;
0 commit comments