Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editors/code: fix crash due to missing ID= field #11710

Merged
merged 1 commit into from Mar 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions editors/code/src/main.ts
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you still sure you don't want this 😄?

Suggested change
return idString.indexOf("nixos") !== -1;
return contents.indexOf("nixos") !== -1;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still kinda am — almost sure two-three years from now someone will find a way to trigger it accidentally :D

} catch {
return false;
}
Expand Down