Skip to content

Commit 3159e87

Browse files
author
Veetaha
committed
vscode: refactor levels of code nesting and string literals quotes
1 parent a3e3fba commit 3159e87

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

editors/code/src/installation/language_server.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,48 @@ export async function ensureLanguageServerBinary(
7171
if (isBinaryAvailable(langServerSource.path)) {
7272
return langServerSource.path;
7373
}
74+
7475
vscode.window.showErrorMessage(
7576
`Unable to run ${langServerSource.path} binary. ` +
76-
"To use the pre-built language server, set `rust-analyzer.raLspServerPath` " +
77+
`To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` +
7778
"value to `null` or remove it from the settings to use it by default."
7879
);
7980
return null;
8081
}
8182
case BinarySource.Type.GithubRelease: {
8283
const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file);
8384

84-
if (!isBinaryAvailable(prebuiltBinaryPath)) {
85-
const userResponse = await vscode.window.showInformationMessage(
86-
"Language server binary for rust-analyzer was not found. " +
87-
"Do you want to download it now?",
88-
"Download now", "Cancel"
89-
);
90-
if (userResponse !== "Download now") return null;
91-
92-
try {
93-
await downloadLatestLanguageServer(langServerSource);
94-
} catch (err) {
95-
await vscode.window.showErrorMessage(
96-
`Failed to download language server from ${langServerSource.repo.name} ` +
97-
`GitHub repository: ${err.message}`
98-
);
99-
return null;
100-
}
101-
102-
103-
assert(
104-
isBinaryAvailable(prebuiltBinaryPath),
105-
"Downloaded language server binary is not functional"
106-
);
85+
if (isBinaryAvailable(prebuiltBinaryPath)) {
86+
return prebuiltBinaryPath;
87+
}
10788

108-
vscode.window.showInformationMessage(
109-
"Rust analyzer language server was successfully installed 🦀"
89+
const userResponse = await vscode.window.showInformationMessage(
90+
"Language server binary for rust-analyzer was not found. " +
91+
"Do you want to download it now?",
92+
"Download now", "Cancel"
93+
);
94+
if (userResponse !== "Download now") return null;
95+
96+
try {
97+
await downloadLatestLanguageServer(langServerSource);
98+
} catch (err) {
99+
await vscode.window.showErrorMessage(
100+
`Failed to download language server from ${langServerSource.repo.name} ` +
101+
`GitHub repository: ${err.message}`
110102
);
103+
return null;
111104
}
105+
106+
107+
assert(
108+
isBinaryAvailable(prebuiltBinaryPath),
109+
"Downloaded language server binary is not functional"
110+
);
111+
112+
vscode.window.showInformationMessage(
113+
"Rust analyzer language server was successfully installed 🦀"
114+
);
115+
112116
return prebuiltBinaryPath;
113117
}
114118
}

0 commit comments

Comments
 (0)