From f7cf3b5503b556f20859da6fe39a4d29dc3af095 Mon Sep 17 00:00:00 2001 From: Vladimir Serov Date: Tue, 15 Mar 2022 06:52:03 +0300 Subject: [PATCH] editors/code: fix crash due to missing ID= field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assuming ID=linux in isNixOs by default. You can get away with default "", but why do that if there's a default value in spec?) Also removed toLowerCase — it really shouldn't be needed. Fixes #11709 --- editors/code/src/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 4856079f68a..06e5c1185d1 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -269,8 +269,8 @@ function serverPath(config: Config): string | null { async function isNixOs(): Promise { try { const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString(); - const idString = contents.split('\n').find((a) => a.startsWith("ID=")); - return idString?.toLowerCase()?.indexOf("nixos") !== -1; + const idString = contents.split('\n').find((a) => a.startsWith("ID=")) || "ID=linux"; + return idString.indexOf("nixos") !== -1; } catch { return false; }