aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/config.ts1
-rw-r--r--editors/code/src/main.ts2
-rw-r--r--editors/code/src/net.ts25
4 files changed, 16 insertions, 17 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 3e6ebd7ed..2225cf1dd 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -633,6 +633,11 @@
633 "default": false, 633 "default": false,
634 "type": "boolean" 634 "type": "boolean"
635 }, 635 },
636 "rust-analyzer.lens.references": {
637 "markdownDescription": "Whether to show `References` lens. Only applies when `#rust-analyzer.lens.enable#` is set.",
638 "default": false,
639 "type": "boolean"
640 },
636 "rust-analyzer.linkedProjects": { 641 "rust-analyzer.linkedProjects": {
637 "markdownDescription": "Disable project auto-discovery in favor of explicitly specified set of projects.\\n\\nElements must be paths pointing to `Cargo.toml`, `rust-project.json`, or JSON objects in `rust-project.json` format.", 642 "markdownDescription": "Disable project auto-discovery in favor of explicitly specified set of projects.\\n\\nElements must be paths pointing to `Cargo.toml`, `rust-project.json`, or JSON objects in `rust-project.json` format.",
638 "default": [], 643 "default": [],
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index ebe4de1ea..ddb5cfbd3 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -144,6 +144,7 @@ export class Config {
144 debug: this.get<boolean>("lens.debug"), 144 debug: this.get<boolean>("lens.debug"),
145 implementations: this.get<boolean>("lens.implementations"), 145 implementations: this.get<boolean>("lens.implementations"),
146 methodReferences: this.get<boolean>("lens.methodReferences"), 146 methodReferences: this.get<boolean>("lens.methodReferences"),
147 references: this.get<boolean>("lens.references"),
147 }; 148 };
148 } 149 }
149 150
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 1edb7713d..1900d900a 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -208,7 +208,6 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
208 url: artifact.browser_download_url, 208 url: artifact.browser_download_url,
209 dest, 209 dest,
210 progressTitle: "Downloading rust-analyzer extension", 210 progressTitle: "Downloading rust-analyzer extension",
211 overwrite: true,
212 }); 211 });
213 }); 212 });
214 213
@@ -340,7 +339,6 @@ async function getServer(config: Config, state: PersistentState): Promise<string
340 progressTitle: "Downloading rust-analyzer server", 339 progressTitle: "Downloading rust-analyzer server",
341 gunzip: true, 340 gunzip: true,
342 mode: 0o755, 341 mode: 0o755,
343 overwrite: true,
344 }); 342 });
345 }); 343 });
346 344
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts
index 1ab21e726..d39dc1baf 100644
--- a/editors/code/src/net.ts
+++ b/editors/code/src/net.ts
@@ -73,23 +73,16 @@ interface DownloadOpts {
73 dest: string; 73 dest: string;
74 mode?: number; 74 mode?: number;
75 gunzip?: boolean; 75 gunzip?: boolean;
76 overwrite?: boolean;
77} 76}
78 77
79export async function download(opts: DownloadOpts) { 78export async function download(opts: DownloadOpts) {
80 // Put artifact into a temporary file (in the same dir for simplicity) 79 // Put artifact into a temporary file (in the same dir for simplicity)
81 // to prevent partially downloaded files when user kills vscode 80 // to prevent partially downloaded files when user kills vscode
81 // This also avoids overwriting running executables
82 const dest = path.parse(opts.dest); 82 const dest = path.parse(opts.dest);
83 const randomHex = crypto.randomBytes(5).toString("hex"); 83 const randomHex = crypto.randomBytes(5).toString("hex");
84 const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`); 84 const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`);
85 85
86 if (opts.overwrite) {
87 // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
88 await fs.promises.unlink(opts.dest).catch(err => {
89 if (err.code !== "ENOENT") throw err;
90 });
91 }
92
93 await vscode.window.withProgress( 86 await vscode.window.withProgress(
94 { 87 {
95 location: vscode.ProgressLocation.Notification, 88 location: vscode.ProgressLocation.Notification,
@@ -99,13 +92,15 @@ export async function download(opts: DownloadOpts) {
99 async (progress, _cancellationToken) => { 92 async (progress, _cancellationToken) => {
100 let lastPercentage = 0; 93 let lastPercentage = 0;
101 await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => { 94 await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => {
102 const newPercentage = (readBytes / totalBytes) * 100; 95 const newPercentage = Math.round((readBytes / totalBytes) * 100);
103 progress.report({ 96 if (newPercentage !== lastPercentage) {
104 message: newPercentage.toFixed(0) + "%", 97 progress.report({
105 increment: newPercentage - lastPercentage 98 message: `${newPercentage.toFixed(0)}%`,
106 }); 99 increment: newPercentage - lastPercentage
107 100 });
108 lastPercentage = newPercentage; 101
102 lastPercentage = newPercentage;
103 }
109 }); 104 });
110 } 105 }
111 ); 106 );