@@ -11,6 +11,23 @@ let ctx: Ctx | undefined;
1111export async function activate ( context : vscode . ExtensionContext ) {
1212 ctx = new Ctx ( context ) ;
1313
14+ ctx . registerCommand ( 'reload' , ( ctx ) => {
15+ return async ( ) => {
16+ vscode . window . showInformationMessage ( 'Reloading rust-analyzer...' ) ;
17+ // @DanTup maneuver
18+ // https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
19+ await deactivate ( )
20+ for ( const sub of ctx . subscriptions ) {
21+ try {
22+ sub . dispose ( ) ;
23+ } catch ( e ) {
24+ console . error ( e ) ;
25+ }
26+ }
27+ await activate ( context )
28+ }
29+ } )
30+
1431 // Commands which invokes manually via command palette, shortcut, etc.
1532 ctx . registerCommand ( 'analyzerStatus' , commands . analyzerStatus ) ;
1633 ctx . registerCommand ( 'collectGarbage' , commands . collectGarbage ) ;
@@ -20,7 +37,6 @@ export async function activate(context: vscode.ExtensionContext) {
2037 ctx . registerCommand ( 'syntaxTree' , commands . syntaxTree ) ;
2138 ctx . registerCommand ( 'expandMacro' , commands . expandMacro ) ;
2239 ctx . registerCommand ( 'run' , commands . run ) ;
23- ctx . registerCommand ( 'reload' , commands . reload ) ;
2440 ctx . registerCommand ( 'onEnter' , commands . onEnter ) ;
2541 ctx . registerCommand ( 'ssr' , commands . ssr )
2642
@@ -38,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) {
3854 //
3955 // This a horribly, horribly wrong way to deal with this problem.
4056 try {
41- await ctx . restartServer ( ) ;
57+ await ctx . startServer ( ) ;
4258 } catch ( e ) {
4359 vscode . window . showErrorMessage ( e . message ) ;
4460 }
@@ -47,4 +63,5 @@ export async function activate(context: vscode.ExtensionContext) {
4763
4864export async function deactivate ( ) {
4965 await ctx ?. client ?. stop ( ) ;
66+ ctx = undefined ;
5067}
0 commit comments