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

Commit 3ec9339

Browse files
committed
Cleaned up implementation of default-channel handling. It was largely unneccesary to pull the getActiveChannel error handling logic out into its own function as a simple short-circuit OR would also do the trick.
1 parent c312108 commit 3ec9339

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/configuration.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,16 @@ export class RLSConfiguration {
6262
configuration: WorkspaceConfiguration,
6363
): string {
6464
const channel = configuration.get<string>('rust-client.channel');
65-
if(channel && channel === "default") {
66-
return RLSConfiguration.defaultOrNightly(wsPath, rustupConfiguration);
67-
} else if(channel) {
68-
return channel;
65+
if(channel === 'default' || !channel) {
66+
try {
67+
return getActiveChannel(wsPath, rustupConfiguration);
68+
} catch (e) {
69+
// rustup might not be installed at the time the configuration is
70+
// initially loaded, so silently ignore the error and return a default value
71+
return 'nightly';
72+
}
6973
} else {
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';
74+
return channel;
8475
}
8576
}
8677

0 commit comments

Comments
 (0)