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

Conversation

cab404
Copy link
Contributor

@cab404 cab404 commented Mar 15, 2022

Assuming ID=linux by default.
Also removed toLowerCase — it really shouldn't be needed.
Fixes #11709

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 rust-lang#11709
@cab404
Copy link
Contributor Author

cab404 commented Mar 15, 2022

@lnicola I did goofed 😅

@cab404 cab404 changed the title isNixOs: fix crash due to missing ID= field editors/code: fix crash due to missing ID= field Mar 15, 2022
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

@lnicola
Copy link
Member

lnicola commented Mar 15, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 15, 2022

@bors bors bot merged commit 88ade42 into rust-lang:master Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rust-analyzer crashes on startup
2 participants