@@ -247,47 +247,43 @@ class RustLanguageClient extends AutoLanguageClient {
247
247
}
248
248
249
249
// check for toolchain updates if installed & not dated
250
- _promptToUpdateToolchain ( ) {
250
+ async _promptToUpdateToolchain ( ) {
251
251
if ( ! atom . config . get ( 'ide-rust.checkForToolchainUpdates' ) ) return
252
252
253
253
const confToolchain = configToolchain ( )
254
254
const dated = confToolchain . match ( DATED_REGEX )
255
255
const toolchain = ( dated ? dated [ 1 ] : confToolchain )
256
256
257
- exec ( `rustup run ${ confToolchain } rustc --version` )
258
- . then ( ( { stdout } ) => fetchLatestDist ( { toolchain, currentVersion : stdout } ) )
259
- . catch ( ( ) => false )
260
- . then ( newVersion => {
261
- if ( newVersion ) {
262
- atom . notifications . addInfo ( `Rls \`${ toolchain } \` toolchain update available` , {
263
- description : newVersion ,
264
- _src : 'ide-rust' ,
265
- dismissable : true ,
266
- buttons : [ {
267
- text : confToolchain === toolchain ? 'Update' : 'Update & Switch' ,
268
- onDidClick : ( ) => {
269
- clearIdeRustInfos ( )
270
-
271
- const updatePromise = exec ( `rustup update ${ toolchain } ` )
272
- // set config in case going from dated -> latest
273
- . then ( ( ) => atom . config . set ( 'ide-rust.rlsToolchain' , toolchain ) )
274
- . then ( ( ) => this . _checkToolchain ( ) )
275
- . then ( ( ) => checkRls ( ) )
276
- . then ( ( ) => this . _restartLanguageServers ( `Updated Rls toolchain` ) )
277
- . catch ( e => console . error ( e ) )
278
-
279
- if ( this . busySignalService ) {
280
- this . busySignalService . reportBusyWhile (
281
- `Updating rust \`${ toolchain } \` toolchain` ,
282
- ( ) => updatePromise
283
- )
284
- }
285
- }
286
- } ]
287
- } )
257
+ let { stdout : currentVersion } = await exec ( `rustup run ${ confToolchain } rustc --version` )
258
+ let newVersion = await fetchLatestDist ( { toolchain, currentVersion } ) . catch ( ( ) => false )
259
+ if ( ! newVersion ) return
260
+
261
+ atom . notifications . addInfo ( `Rls \`${ toolchain } \` toolchain update available` , {
262
+ description : newVersion ,
263
+ _src : 'ide-rust' ,
264
+ dismissable : true ,
265
+ buttons : [ {
266
+ text : confToolchain === toolchain ? 'Update' : 'Update & Switch' ,
267
+ onDidClick : ( ) => {
268
+ clearIdeRustInfos ( )
269
+
270
+ const updatePromise = exec ( `rustup update ${ toolchain } ` )
271
+ // set config in case going from dated -> latest
272
+ . then ( ( ) => atom . config . set ( 'ide-rust.rlsToolchain' , toolchain ) )
273
+ . then ( ( ) => this . _checkToolchain ( ) )
274
+ . then ( ( ) => checkRls ( ) )
275
+ . then ( ( ) => this . _restartLanguageServers ( `Updated Rls toolchain` ) )
276
+ . catch ( e => console . error ( e ) )
277
+
278
+ if ( this . busySignalService ) {
279
+ this . busySignalService . reportBusyWhile (
280
+ `Updating rust \`${ toolchain } \` toolchain` ,
281
+ ( ) => updatePromise
282
+ )
283
+ }
288
284
}
289
- } )
290
- . catch ( e => console . error ( e ) )
285
+ } ]
286
+ } )
291
287
}
292
288
293
289
/**
0 commit comments