From 69b6f6def525d33a60a3a992960d1085403d3b60 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Thu, 2 Jul 2020 04:56:50 +0300 Subject: Always install required nightly extension if current one is not nightly --- editors/code/src/main.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 5ceab8b44..1ad75a03c 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -152,13 +152,17 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi return; }; - const lastCheck = state.lastCheck; const now = Date.now(); + if (config.package.releaseTag === NIGHTLY_TAG) { + // Check if we should poll github api for the new nightly version + // if we haven't done it during the past hour + const lastCheck = state.lastCheck; - const anHour = 60 * 60 * 1000; - const shouldDownloadNightly = state.releaseId === undefined || (now - (lastCheck ?? 0)) > anHour; + const anHour = 60 * 60 * 1000; + const shouldCheckForNewNightly = state.releaseId === undefined || (now - (lastCheck ?? 0)) > anHour; - if (!shouldDownloadNightly) return; + if (!shouldCheckForNewNightly) return; + } const release = await fetchRelease("nightly").catch((e) => { log.error(e); -- cgit v1.2.3 From 6a6ce616aa8da460a145a8d535357adef9f51678 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Thu, 2 Jul 2020 05:19:02 +0300 Subject: Force showing extension activation error pop-up notification --- editors/code/src/main.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 5ceab8b44..ed26c887b 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -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 -- cgit v1.2.3