diff options
| author | Vladimir Serov <me@cab404.ru> | 2022-03-13 00:26:36 +0300 |
|---|---|---|
| committer | Vladimir Serov <me@cab404.ru> | 2022-03-13 00:38:41 +0300 |
| commit | ce4b61003d8eb5383c4e759d919cdc72a137bc11 (patch) | |
| tree | 4290e85d509a3f2499c477369121c85ec80a8032 /editors/code | |
| parent | 5fcf979f8a09e6504bbe540cbff6d640b959935c (diff) | |
| download | rust-ce4b61003d8eb5383c4e759d919cdc72a137bc11.tar.gz rust-ce4b61003d8eb5383c4e759d919cdc72a137bc11.zip | |
editors/code: fix nixos detection
Problem: NixOS started using quotes around it's id field in /etc/os-release Solution: Parially parsing os-release, and detecting, whether `nixos` appears anywhere in "ID=" field\ See https://github.com/rust-analyzer/rust-analyzer/issues/11695 Closes #11695
Diffstat (limited to 'editors/code')
| -rw-r--r-- | editors/code/src/main.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 3f9f0b3376e..4856079f68a 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -269,7 +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(); - return contents.indexOf("ID=nixos") !== -1; + const idString = contents.split('\n').find((a) => a.startsWith("ID=")); + return idString?.toLowerCase()?.indexOf("nixos") !== -1; } catch { return false; } |
