aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 5a99e96f0..ec488c340 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -11,6 +11,23 @@ let ctx: Ctx | undefined;
11export async function activate(context: vscode.ExtensionContext) { 11export async function activate(context: vscode.ExtensionContext) {
12 ctx = new Ctx(context); 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 // Commands which invokes manually via command palette, shortcut, etc. 31 // Commands which invokes manually via command palette, shortcut, etc.
15 ctx.registerCommand('analyzerStatus', commands.analyzerStatus); 32 ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
16 ctx.registerCommand('collectGarbage', commands.collectGarbage); 33 ctx.registerCommand('collectGarbage', commands.collectGarbage);
@@ -20,7 +37,6 @@ export async function activate(context: vscode.ExtensionContext) {
20 ctx.registerCommand('syntaxTree', commands.syntaxTree); 37 ctx.registerCommand('syntaxTree', commands.syntaxTree);
21 ctx.registerCommand('expandMacro', commands.expandMacro); 38 ctx.registerCommand('expandMacro', commands.expandMacro);
22 ctx.registerCommand('run', commands.run); 39 ctx.registerCommand('run', commands.run);
23 ctx.registerCommand('reload', commands.reload);
24 ctx.registerCommand('onEnter', commands.onEnter); 40 ctx.registerCommand('onEnter', commands.onEnter);
25 ctx.registerCommand('ssr', commands.ssr) 41 ctx.registerCommand('ssr', commands.ssr)
26 42
@@ -38,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) {
38 // 54 //
39 // This a horribly, horribly wrong way to deal with this problem. 55 // This a horribly, horribly wrong way to deal with this problem.
40 try { 56 try {
41 await ctx.restartServer(); 57 await ctx.startServer();
42 } catch (e) { 58 } catch (e) {
43 vscode.window.showErrorMessage(e.message); 59 vscode.window.showErrorMessage(e.message);
44 } 60 }
@@ -47,4 +63,5 @@ export async function activate(context: vscode.ExtensionContext) {
47 63
48export async function deactivate() { 64export async function deactivate() {
49 await ctx?.client?.stop(); 65 await ctx?.client?.stop();
66 ctx = undefined;
50} 67}