aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/main.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 191960960..4b2d3c8a5 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -19,9 +19,8 @@ let ctx: Ctx | undefined;
19const RUST_PROJECT_CONTEXT_NAME = "inRustProject"; 19const RUST_PROJECT_CONTEXT_NAME = "inRustProject";
20 20
21export async function activate(context: vscode.ExtensionContext) { 21export async function activate(context: vscode.ExtensionContext) {
22 // For some reason vscode not always shows pop-up error notifications 22 // VS Code doesn't show a notification when an extension fails to activate
23 // when an extension fails to activate, so we do it explicitly by ourselves. 23 // so we do it 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 => { 24 await tryActivate(context).catch(err => {
26 void vscode.window.showErrorMessage(`Cannot activate rust-analyzer: ${err.message}`); 25 void vscode.window.showErrorMessage(`Cannot activate rust-analyzer: ${err.message}`);
27 throw err; 26 throw err;
@@ -292,6 +291,8 @@ async function getServer(config: Config, state: PersistentState): Promise<string
292 if (process.platform === "linux") platform = "linux"; 291 if (process.platform === "linux") platform = "linux";
293 if (process.platform === "darwin") platform = "mac"; 292 if (process.platform === "darwin") platform = "mac";
294 if (process.platform === "win32") platform = "windows"; 293 if (process.platform === "win32") platform = "windows";
294 } else if (process.arch === "arm64" && process.platform === "darwin") {
295 platform = "mac";
295 } 296 }
296 if (platform === undefined) { 297 if (platform === undefined) {
297 vscode.window.showErrorMessage( 298 vscode.window.showErrorMessage(
@@ -340,7 +341,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
340 }); 341 });
341 342
342 // Patching executable if that's NixOS. 343 // Patching executable if that's NixOS.
343 if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { 344 if (await isNixOs()) {
344 await patchelf(dest); 345 await patchelf(dest);
345 } 346 }
346 347
@@ -348,6 +349,15 @@ async function getServer(config: Config, state: PersistentState): Promise<string
348 return dest; 349 return dest;
349} 350}
350 351
352async function isNixOs(): Promise<boolean> {
353 try {
354 const contents = await fs.readFile("/etc/os-release");
355 return contents.indexOf("ID=nixos") !== -1;
356 } catch (e) {
357 return false;
358 }
359}
360
351async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> { 361async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> {
352 while (true) { 362 while (true) {
353 try { 363 try {