Skip to content

Force showing extension activation error pop-up notification #5185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions editors/code/src/main.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,16 @@ let ctx: Ctx | undefined;
const RUST_PROJECT_CONTEXT_NAME = "inRustProject";

export async function activate(context: vscode.ExtensionContext) {
// For some reason vscode not always shows pop-up error notifications
// when an extension fails to activate, so we do it explicitly by ourselves.
// FIXME: remove this bit of code once vscode fixes this issue: https://github.com/microsoft/vscode/issues/101242
await tryActivate(context).catch(err => {
void vscode.window.showErrorMessage(`Cannot activate rust-analyzer: ${err.message}`);
throw err;
});
}

async function tryActivate(context: vscode.ExtensionContext) {
// Register a "dumb" onEnter command for the case where server fails to
// start.
//
@@ -58,9 +68,7 @@ export async function activate(context: vscode.ExtensionContext) {

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

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