Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit c312108

Browse files
committed
This patch address the inability to specify the default active toolchain as the active channel.
This can be painful for nightly because RLS is not always available.
1 parent c85bf69 commit c312108

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"null"
197197
],
198198
"enum": [
199+
"default",
199200
"stable",
200201
"beta",
201202
"nightly"

src/configuration.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,25 @@ export class RLSConfiguration {
6262
configuration: WorkspaceConfiguration,
6363
): string {
6464
const channel = configuration.get<string>('rust-client.channel');
65-
if (channel) {
65+
if(channel && channel === "default") {
66+
return RLSConfiguration.defaultOrNightly(wsPath, rustupConfiguration);
67+
} else if(channel) {
6668
return channel;
6769
} else {
68-
try {
69-
return getActiveChannel(wsPath, rustupConfiguration);
70-
} catch (e) {
71-
// rustup might not be installed at the time the configuration is
72-
// initially loaded, so silently ignore the error and return a default value
73-
return 'nightly';
74-
}
70+
return RLSConfiguration.defaultOrNightly(wsPath, rustupConfiguration);
71+
}
72+
}
73+
74+
private static defaultOrNightly(
75+
wsPath: string,
76+
rustupConfiguration: RustupConfig,
77+
): string {
78+
try {
79+
return getActiveChannel(wsPath, rustupConfiguration);
80+
} catch (e) {
81+
// rustup might not be installed at the time the configuration is
82+
// initially loaded, so silently ignore the error and return a default value
83+
return 'nightly';
7584
}
7685
}
7786

src/rustup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function getActiveChannel(wsPath: string, config: RustupConfig): string {
274274
}
275275

276276
console.info(
277-
`Detected active channel: ${activeChannel} (since 'rust-client.channel' is unspecified)`,
277+
`Using active channel: ${activeChannel}`,
278278
);
279279
return activeChannel;
280280
}

0 commit comments

Comments
 (0)