Skip to content

Commit b42c0e8

Browse files
raggiKalitaAlexey
authored andcommitted
rustup: if the user only has one toolchain, use it (editor-rs#340)
This fixes one common use case of editor-rs#339, but not all. If the user only has one toolchain, and it's a nightly, just use that instead of doing the configuration prompt dance.
1 parent b03b857 commit b42c0e8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/configuration/Rustup.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ export class Rustup {
110110
* Returns either the nightly toolchain chosen by the user or undefined
111111
*/
112112
public getUserNightlyToolchain(): Toolchain | undefined {
113-
return this._userNightlyToolchain;
113+
if (this._userNightlyToolchain) {
114+
return this._userNightlyToolchain;
115+
}
116+
const defaultToolchain = this.getDefaultToolchain();
117+
if (defaultToolchain && defaultToolchain.channel === 'nightly') {
118+
return defaultToolchain;
119+
}
120+
return undefined;
114121
}
115122

116123
/**
@@ -128,10 +135,10 @@ export class Rustup {
128135
}
129136

130137
/**
131-
* Returns either the toolchain chosen by the user or undefined
138+
* Returns either the toolchain chosen by the user or the default or undefined
132139
*/
133140
public getUserToolchain(): Toolchain | undefined {
134-
return this._userToolchain;
141+
return this._userToolchain || this.getDefaultToolchain();
135142
}
136143

137144
public setUserToolchain(toolchain: Toolchain | undefined): void {

0 commit comments

Comments
 (0)