@@ -48,21 +48,19 @@ export async function activate(context: vscode.ExtensionContext) {
4848 ctx = await Ctx . create ( config , context , serverPath ) ;
4949
5050 // Commands which invokes manually via command palette, shortcut, etc.
51- ctx . registerCommand ( 'reload' , ( ctx ) => {
52- return async ( ) => {
53- vscode . window . showInformationMessage ( 'Reloading rust-analyzer...' ) ;
54- // @DanTup maneuver
55- // https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
56- await deactivate ( ) ;
57- for ( const sub of ctx . subscriptions ) {
58- try {
59- sub . dispose ( ) ;
60- } catch ( e ) {
61- log . error ( e ) ;
62- }
51+
52+ // Reloading is inspired by @DanTup maneuver: https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
53+ ctx . registerCommand ( 'reload' , _ => async ( ) => {
54+ void vscode . window . showInformationMessage ( 'Reloading rust-analyzer...' ) ;
55+ await deactivate ( ) ;
56+ while ( context . subscriptions . length > 0 ) {
57+ try {
58+ context . subscriptions . pop ( ) ! . dispose ( ) ;
59+ } catch ( err ) {
60+ log . error ( "Dispose error:" , err ) ;
6361 }
64- await activate ( context ) ;
65- } ;
62+ }
63+ await activate ( context ) . catch ( log . error ) ;
6664 } ) ;
6765
6866 ctx . registerCommand ( 'analyzerStatus' , commands . analyzerStatus ) ;
@@ -96,7 +94,7 @@ export async function activate(context: vscode.ExtensionContext) {
9694}
9795
9896export async function deactivate ( ) {
99- await ctx ?. client ? .stop ( ) ;
97+ await ctx ?. client . stop ( ) ;
10098 ctx = undefined ;
10199}
102100
0 commit comments