@@ -11,6 +11,23 @@ let ctx: Ctx | undefined;
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
ctx = new Ctx(context);
|
||||
|
||||
ctx.registerCommand('reload', (ctx) => {
|
||||
return async () => {
|
||||
vscode.window.showInformationMessage('Reloading rust-analyzer...');
|
||||
// @DanTup maneuver
|
||||
// https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
|
||||
await deactivate()
|
||||
for (const sub of ctx.subscriptions) {
|
||||
try {
|
||||
sub.dispose();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
await activate(context)
|
||||
}
|
||||
})
|
||||
|
||||
// Commands which invokes manually via command palette, shortcut, etc.
|
||||
ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
|
||||
ctx.registerCommand('collectGarbage', commands.collectGarbage);
|
||||
@@ -20,7 +37,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
ctx.registerCommand('syntaxTree', commands.syntaxTree);
|
||||
ctx.registerCommand('expandMacro', commands.expandMacro);
|
||||
ctx.registerCommand('run', commands.run);
|
||||
ctx.registerCommand('reload', commands.reload);
|
||||
ctx.registerCommand('onEnter', commands.onEnter);
|
||||
ctx.registerCommand('ssr', commands.ssr)
|
||||
|
||||
@@ -38,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
//
|
||||
// This a horribly, horribly wrong way to deal with this problem.
|
||||
try {
|
||||
await ctx.restartServer();
|
||||
await ctx.startServer();
|
||||
} catch (e) {
|
||||
vscode.window.showErrorMessage(e.message);
|
||||
}
|
||||
@@ -47,4 +63,5 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
export async function deactivate() {
|
||||
await ctx?.client?.stop();
|
||||
ctx = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user