@@ -11,6 +11,23 @@ let ctx: Ctx | undefined;
11
11
export async function activate ( context : vscode . ExtensionContext ) {
12
12
ctx = new Ctx ( context ) ;
13
13
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
+
14
31
// Commands which invokes manually via command palette, shortcut, etc.
15
32
ctx . registerCommand ( 'analyzerStatus' , commands . analyzerStatus ) ;
16
33
ctx . registerCommand ( 'collectGarbage' , commands . collectGarbage ) ;
@@ -20,7 +37,6 @@ export async function activate(context: vscode.ExtensionContext) {
20
37
ctx . registerCommand ( 'syntaxTree' , commands . syntaxTree ) ;
21
38
ctx . registerCommand ( 'expandMacro' , commands . expandMacro ) ;
22
39
ctx . registerCommand ( 'run' , commands . run ) ;
23
- ctx . registerCommand ( 'reload' , commands . reload ) ;
24
40
ctx . registerCommand ( 'onEnter' , commands . onEnter ) ;
25
41
ctx . registerCommand ( 'ssr' , commands . ssr )
26
42
@@ -38,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) {
38
54
//
39
55
// This a horribly, horribly wrong way to deal with this problem.
40
56
try {
41
- await ctx . restartServer ( ) ;
57
+ await ctx . startServer ( ) ;
42
58
} catch ( e ) {
43
59
vscode . window . showErrorMessage ( e . message ) ;
44
60
}
@@ -47,4 +63,5 @@ export async function activate(context: vscode.ExtensionContext) {
47
63
48
64
export async function deactivate ( ) {
49
65
await ctx ?. client ?. stop ( ) ;
66
+ ctx = undefined ;
50
67
}
0 commit comments