diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-18 18:32:20 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-18 18:32:20 +0000 |
| commit | 4c686721c0fe4dd8fef74acb502c2327e0054dff (patch) | |
| tree | 01132deef76e0bbe7e0af0c3dde7db79de4d52fc | |
| parent | 81d0096000dd2e30144143235f76546c34ddf5cd (diff) | |
| parent | 262a698875b4b46b63137777e8d948ee22fef240 (diff) | |
| download | rust-4c686721c0fe4dd8fef74acb502c2327e0054dff.tar.gz rust-4c686721c0fe4dd8fef74acb502c2327e0054dff.zip | |
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 <lnicola@dend.ro>
| -rw-r--r-- | docs/user/manual.adoc | 2 | ||||
| -rw-r--r-- | editors/code/.vscodeignore | 1 | ||||
| -rw-r--r-- | editors/code/src/config.ts | 2 | ||||
| -rw-r--r-- | editors/code/src/main.ts | 15 |
4 files changed, 19 insertions, 1 deletions
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index 4fbe2379c3d..cfcad7c66b7 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc @@ -74,6 +74,8 @@ The server binary is stored in: * macOS: `~/Library/Application\ Support/Code/User/globalStorage/matklad.rust-analyzer` * Windows: `%APPDATA%\Code\User\globalStorage\matklad.rust-analyzer` +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`. + Note that we only support two most recent versions of VS Code. ==== Updates diff --git a/editors/code/.vscodeignore b/editors/code/.vscodeignore index ec3c10e0258..09dc27056b3 100644 --- a/editors/code/.vscodeignore +++ b/editors/code/.vscodeignore @@ -10,4 +10,5 @@ !package-lock.json !package.json !ra_syntax_tree.tmGrammar.json +!server !README.md diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 58947118c92..cb0868db597 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -36,9 +36,11 @@ export class Config { } = vscode.extensions.getExtension(this.extensionId)!.packageJSON; readonly globalStorageUri: vscode.Uri; + readonly installUri: vscode.Uri; constructor(ctx: vscode.ExtensionContext) { this.globalStorageUri = ctx.globalStorageUri; + this.installUri = ctx.extensionUri; vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, ctx.subscriptions); this.refreshLogging(); } diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a06fc09fc8e..e2a9c4c737d 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -345,7 +345,20 @@ async function getServer(config: Config, state: PersistentState): Promise<string } const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; const dest = vscode.Uri.joinPath(config.globalStorageUri, `rust-analyzer-${platform}${ext}`); - const exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false); + const bundled = vscode.Uri.joinPath(config.installUri, "server", `rust-analyzer${ext}`); + const bundledExists = await vscode.workspace.fs.stat(bundled).then(() => true, () => false); + let exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false); + if (bundledExists) { + await state.updateServerVersion(config.package.version); + if (!await isNixOs()) { + return bundled.fsPath; + } + if (!exists) { + await vscode.workspace.fs.copy(bundled, dest); + await patchelf(dest); + exists = true; + } + } if (!exists) { await state.updateServerVersion(undefined); } |
