Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 1694a69

Browse files
committed
Force showing extension activation error pop-up notification
1 parent 674f82b commit 1694a69

File tree

1 file changed

+11
-3
lines changed
  • rust-analyzer/editors/code/src

1 file changed

+11
-3
lines changed

rust-analyzer/editors/code/src/main.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ let ctx: Ctx | undefined;
1919
const RUST_PROJECT_CONTEXT_NAME = "inRustProject";
2020

2121
export async function activate(context: vscode.ExtensionContext) {
22+
// For some reason vscode not always shows pop-up error notifications
23+
// when an extension fails to activate, so we do it explicitly by ourselves.
24+
// FIXME: remove this bit of code once vscode fixes this issue: https://github.com/microsoft/vscode/issues/101242
25+
await tryActivate(context).catch(err => {
26+
void vscode.window.showErrorMessage(`Cannot activate rust-analyzer: ${err.message}`);
27+
throw err;
28+
});
29+
}
30+
31+
async function tryActivate(context: vscode.ExtensionContext) {
2232
// Register a "dumb" onEnter command for the case where server fails to
2333
// start.
2434
//
@@ -58,9 +68,7 @@ export async function activate(context: vscode.ExtensionContext) {
5868

5969
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
6070
if (workspaceFolder === undefined) {
61-
const err = "Cannot activate rust-analyzer when no folder is opened";
62-
void vscode.window.showErrorMessage(err);
63-
throw new Error(err);
71+
throw new Error("no folder is opened");
6472
}
6573

6674
// Note: we try to start the server before we activate type hints so that it

0 commit comments

Comments
 (0)