diff options
| author | Vladimir Serov <me@cab404.ru> | 2022-03-15 06:52:03 +0300 |
|---|---|---|
| committer | Vladimir Serov <me@cab404.ru> | 2022-03-15 07:11:24 +0300 |
| commit | f7cf3b5503b556f20859da6fe39a4d29dc3af095 (patch) | |
| tree | 75d97ed05835c9710ea1177497b928419e77653b | |
| parent | 683fea4de4f0e994b585823f99d42ad469749ea5 (diff) | |
| download | rust-f7cf3b5503b556f20859da6fe39a4d29dc3af095.tar.gz rust-f7cf3b5503b556f20859da6fe39a4d29dc3af095.zip | |
editors/code: fix crash due to missing ID= field
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
| -rw-r--r-- | editors/code/src/main.ts | 4 |
1 files 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<boolean> { 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; } |
