Skip to content

Commit 4c68672

Browse files
bors[bot]lnicola
andauthored
Merge #11047
11047: internal: Prepare Code extension for bundling r=lnicola a=lnicola CC #10483 This is slightly ugly, but we'll be able to clean it up after ripping the download parts (unless we decide to temporarily drop support for the nightlies). Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 81d0096 + 262a698 commit 4c68672

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

docs/user/manual.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ The server binary is stored in:
7474
* macOS: `~/Library/Application\ Support/Code/User/globalStorage/matklad.rust-analyzer`
7575
* Windows: `%APPDATA%\Code\User\globalStorage\matklad.rust-analyzer`
7676

77+
However, if you are using a version of the extension with a bundled server binary and you are not running NixOS, the server binary might be instead running from: `~/.vscode/extensions/matklad.rust-analyzer-VERSION`.
78+
7779
Note that we only support two most recent versions of VS Code.
7880

7981
==== Updates

editors/code/.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
!package-lock.json
1111
!package.json
1212
!ra_syntax_tree.tmGrammar.json
13+
!server
1314
!README.md

editors/code/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ export class Config {
3636
} = vscode.extensions.getExtension(this.extensionId)!.packageJSON;
3737

3838
readonly globalStorageUri: vscode.Uri;
39+
readonly installUri: vscode.Uri;
3940

4041
constructor(ctx: vscode.ExtensionContext) {
4142
this.globalStorageUri = ctx.globalStorageUri;
43+
this.installUri = ctx.extensionUri;
4244
vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, ctx.subscriptions);
4345
this.refreshLogging();
4446
}

editors/code/src/main.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,20 @@ async function getServer(config: Config, state: PersistentState): Promise<string
345345
}
346346
const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
347347
const dest = vscode.Uri.joinPath(config.globalStorageUri, `rust-analyzer-${platform}${ext}`);
348-
const exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false);
348+
const bundled = vscode.Uri.joinPath(config.installUri, "server", `rust-analyzer${ext}`);
349+
const bundledExists = await vscode.workspace.fs.stat(bundled).then(() => true, () => false);
350+
let exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false);
351+
if (bundledExists) {
352+
await state.updateServerVersion(config.package.version);
353+
if (!await isNixOs()) {
354+
return bundled.fsPath;
355+
}
356+
if (!exists) {
357+
await vscode.workspace.fs.copy(bundled, dest);
358+
await patchelf(dest);
359+
exists = true;
360+
}
361+
}
349362
if (!exists) {
350363
await state.updateServerVersion(undefined);
351364
}

0 commit comments

Comments
 (0)