Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 84f0a5810f..97ec41dce3 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -14,6 +14,10 @@ export interface RustAnalyzerExtensionApi {
readonly client?: lc.LanguageClient;
}
+export async function deactivate() {
+ await setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined);
+}
+
export async function activate(
context: vscode.ExtensionContext
): Promise<RustAnalyzerExtensionApi> {
@@ -56,12 +60,14 @@ export async function activate(
const ctx = new Ctx(context, workspace);
// VS Code doesn't show a notification when an extension fails to activate
// so we do it ourselves.
- return await activateServer(ctx).catch((err) => {
+ const api = await activateServer(ctx).catch((err) => {
void vscode.window.showErrorMessage(
`Cannot activate rust-analyzer extension: ${err.message}`
);
throw err;
});
+ await setContextValue(RUST_PROJECT_CONTEXT_NAME, true);
+ return api;
}
async function activateServer(ctx: Ctx): Promise<RustAnalyzerExtensionApi> {
@@ -112,8 +118,6 @@ async function initCommonContext(ctx: Ctx) {
);
ctx.pushExtCleanup(defaultOnEnter);
- await setContextValue(RUST_PROJECT_CONTEXT_NAME, true);
-
// Commands which invokes manually via command palette, shortcut, etc.
ctx.registerCommand("reload", (_) => async () => {
void vscode.window.showInformationMessage("Reloading rust-analyzer...");