@@ -9,7 +9,7 @@ import { activateStatusDisplay } from './status_display';
99import { Ctx } from './ctx' ;
1010import { activateHighlighting } from './highlighting' ;
1111import { Config , NIGHTLY_TAG } from './config' ;
12- import { log , assert } from './util' ;
12+ import { log , assert , dispose } from './util' ;
1313import { PersistentState } from './persistent_state' ;
1414import { fetchRelease , download } from './net' ;
1515import { spawnSync } from 'child_process' ;
@@ -48,21 +48,12 @@ 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- }
63- }
64- await activate ( context ) ;
65- } ;
51+
52+ // Reloading is inspired by @DanTup maneuver: https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
53+ ctx . registerCommand ( 'reload' , _ => ( ) => {
54+ void vscode . window . showInformationMessage ( 'Reloading rust-analyzer...' ) ;
55+
56+ deactivate ( ) . then ( ( ) => activate ( context ) ) . catch ( log . error ) ;
6657 } ) ;
6758
6859 ctx . registerCommand ( 'analyzerStatus' , commands . analyzerStatus ) ;
@@ -74,7 +65,7 @@ export async function activate(context: vscode.ExtensionContext) {
7465 ctx . registerCommand ( 'expandMacro' , commands . expandMacro ) ;
7566 ctx . registerCommand ( 'run' , commands . run ) ;
7667
77- defaultOnEnter . dispose ( ) ;
68+ dispose ( defaultOnEnter ) ;
7869 ctx . registerCommand ( 'onEnter' , commands . onEnter ) ;
7970
8071 ctx . registerCommand ( 'ssr' , commands . ssr ) ;
@@ -96,7 +87,7 @@ export async function activate(context: vscode.ExtensionContext) {
9687}
9788
9889export async function deactivate ( ) {
99- await ctx ?. client ?. stop ( ) ;
90+ await ctx ?. dispose ( ) ;
10091 ctx = undefined ;
10192}
10293
0 commit comments