diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/package-lock.json | 12 | ||||
-rw-r--r-- | editors/code/package.json | 29 | ||||
-rw-r--r-- | editors/code/src/main.ts | 14 | ||||
-rw-r--r-- | editors/code/src/net.ts | 18 | ||||
-rw-r--r-- | editors/code/src/toolchain.ts | 16 |
5 files changed, 57 insertions, 32 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 52ffc0f9f..d22c80754 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -986,9 +986,9 @@ | |||
986 | } | 986 | } |
987 | }, | 987 | }, |
988 | "node_modules/css-what": { | 988 | "node_modules/css-what": { |
989 | "version": "5.0.0", | 989 | "version": "5.0.1", |
990 | "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.0.tgz", | 990 | "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.1.tgz", |
991 | "integrity": "sha512-qxyKHQvgKwzwDWC/rGbT821eJalfupxYW2qbSJSAtdSTimsr/MlaGONoNLllaUPZWf8QnbcKM/kPVYUQuEKAFA==", | 991 | "integrity": "sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg==", |
992 | "dev": true, | 992 | "dev": true, |
993 | "engines": { | 993 | "engines": { |
994 | "node": ">= 6" | 994 | "node": ">= 6" |
@@ -4345,9 +4345,9 @@ | |||
4345 | } | 4345 | } |
4346 | }, | 4346 | }, |
4347 | "css-what": { | 4347 | "css-what": { |
4348 | "version": "5.0.0", | 4348 | "version": "5.0.1", |
4349 | "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.0.tgz", | 4349 | "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.1.tgz", |
4350 | "integrity": "sha512-qxyKHQvgKwzwDWC/rGbT821eJalfupxYW2qbSJSAtdSTimsr/MlaGONoNLllaUPZWf8QnbcKM/kPVYUQuEKAFA==", | 4350 | "integrity": "sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg==", |
4351 | "dev": true | 4351 | "dev": true |
4352 | }, | 4352 | }, |
4353 | "debug": { | 4353 | "debug": { |
diff --git a/editors/code/package.json b/editors/code/package.json index 43a5cc2b5..666016ae4 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -313,7 +313,7 @@ | |||
313 | }, | 313 | }, |
314 | "rust-analyzer.updates.askBeforeDownload": { | 314 | "rust-analyzer.updates.askBeforeDownload": { |
315 | "type": "boolean", | 315 | "type": "boolean", |
316 | "default": true, | 316 | "default": false, |
317 | "description": "Whether to ask for permission before downloading any files from the Internet." | 317 | "description": "Whether to ask for permission before downloading any files from the Internet." |
318 | }, | 318 | }, |
319 | "rust-analyzer.server.path": { | 319 | "rust-analyzer.server.path": { |
@@ -389,7 +389,7 @@ | |||
389 | "default": {}, | 389 | "default": {}, |
390 | "markdownDescription": "Optional settings passed to the debug engine. Example: `{ \"lldb\": { \"terminal\":\"external\"} }`" | 390 | "markdownDescription": "Optional settings passed to the debug engine. Example: `{ \"lldb\": { \"terminal\":\"external\"} }`" |
391 | }, | 391 | }, |
392 | "$generated-start": false, | 392 | "$generated-start": {}, |
393 | "rust-analyzer.assist.importGranularity": { | 393 | "rust-analyzer.assist.importGranularity": { |
394 | "markdownDescription": "How imports should be grouped into use statements.", | 394 | "markdownDescription": "How imports should be grouped into use statements.", |
395 | "default": "crate", | 395 | "default": "crate", |
@@ -418,13 +418,13 @@ | |||
418 | "type": "string", | 418 | "type": "string", |
419 | "enum": [ | 419 | "enum": [ |
420 | "plain", | 420 | "plain", |
421 | "by_self", | 421 | "self", |
422 | "by_crate" | 422 | "crate" |
423 | ], | 423 | ], |
424 | "enumDescriptions": [ | 424 | "enumDescriptions": [ |
425 | "Insert import paths relative to the current module, using up to one `super` prefix if the parent module contains the requested item.", | 425 | "Insert import paths relative to the current module, using up to one `super` prefix if the parent module contains the requested item.", |
426 | "Prefix all import paths with `self` if they don't begin with `self`, `super`, `crate` or a crate name.", | 426 | "Insert import paths relative to the current module, using up to one `super` prefix if the parent module contains the requested item. Prefixes `self` in front of the path if it starts with a module.", |
427 | "Force import paths to be absolute by always starting them with `crate` or the crate name they refer to." | 427 | "Force import paths to be absolute by always starting them with `crate` or the extern crate name they come from." |
428 | ] | 428 | ] |
429 | }, | 429 | }, |
430 | "rust-analyzer.assist.importGroup": { | 430 | "rust-analyzer.assist.importGroup": { |
@@ -432,6 +432,11 @@ | |||
432 | "default": true, | 432 | "default": true, |
433 | "type": "boolean" | 433 | "type": "boolean" |
434 | }, | 434 | }, |
435 | "rust-analyzer.assist.allowMergingIntoGlobImports": { | ||
436 | "markdownDescription": "Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.", | ||
437 | "default": true, | ||
438 | "type": "boolean" | ||
439 | }, | ||
435 | "rust-analyzer.callInfo.full": { | 440 | "rust-analyzer.callInfo.full": { |
436 | "markdownDescription": "Show function name and docs in parameter hints.", | 441 | "markdownDescription": "Show function name and docs in parameter hints.", |
437 | "default": true, | 442 | "default": true, |
@@ -447,6 +452,16 @@ | |||
447 | "default": false, | 452 | "default": false, |
448 | "type": "boolean" | 453 | "type": "boolean" |
449 | }, | 454 | }, |
455 | "rust-analyzer.cargo.unsetTest": { | ||
456 | "markdownDescription": "Unsets `#[cfg(test)]` for the specified crates.", | ||
457 | "default": [ | ||
458 | "core" | ||
459 | ], | ||
460 | "type": "array", | ||
461 | "items": { | ||
462 | "type": "string" | ||
463 | } | ||
464 | }, | ||
450 | "rust-analyzer.cargo.features": { | 465 | "rust-analyzer.cargo.features": { |
451 | "markdownDescription": "List of features to activate.", | 466 | "markdownDescription": "List of features to activate.", |
452 | "default": [], | 467 | "default": [], |
@@ -846,7 +861,7 @@ | |||
846 | "Search for all symbols kinds" | 861 | "Search for all symbols kinds" |
847 | ] | 862 | ] |
848 | }, | 863 | }, |
849 | "$generated-end": false | 864 | "$generated-end": {} |
850 | } | 865 | } |
851 | }, | 866 | }, |
852 | "problemPatterns": [ | 867 | "problemPatterns": [ |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index f58d26215..15f2151ad 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -158,7 +158,7 @@ export async function deactivate() { | |||
158 | } | 158 | } |
159 | 159 | ||
160 | async function bootstrap(config: Config, state: PersistentState): Promise<string> { | 160 | async function bootstrap(config: Config, state: PersistentState): Promise<string> { |
161 | await vscode.workspace.fs.createDirectory(config.globalStorageUri); | 161 | await vscode.workspace.fs.createDirectory(config.globalStorageUri).then(); |
162 | 162 | ||
163 | if (!config.currentExtensionIsNightly) { | 163 | if (!config.currentExtensionIsNightly) { |
164 | await state.updateNightlyReleaseId(undefined); | 164 | await state.updateNightlyReleaseId(undefined); |
@@ -277,11 +277,11 @@ async function patchelf(dest: vscode.Uri): Promise<void> { | |||
277 | ''; | 277 | ''; |
278 | } | 278 | } |
279 | `; | 279 | `; |
280 | const origFile = vscode.Uri.file(dest.path + "-orig"); | 280 | const origFile = vscode.Uri.file(dest.fsPath + "-orig"); |
281 | await vscode.workspace.fs.rename(dest, origFile); | 281 | await vscode.workspace.fs.rename(dest, origFile); |
282 | progress.report({ message: "Patching executable", increment: 20 }); | 282 | progress.report({ message: "Patching executable", increment: 20 }); |
283 | await new Promise((resolve, reject) => { | 283 | await new Promise((resolve, reject) => { |
284 | const handle = exec(`nix-build -E - --argstr srcStr '${origFile.path}' -o '${dest.path}'`, | 284 | const handle = exec(`nix-build -E - --argstr srcStr '${origFile.fsPath}' -o '${dest.fsPath}'`, |
285 | (err, stdout, stderr) => { | 285 | (err, stdout, stderr) => { |
286 | if (err != null) { | 286 | if (err != null) { |
287 | reject(Error(stderr)); | 287 | reject(Error(stderr)); |
@@ -338,14 +338,14 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
338 | await state.updateServerVersion(undefined); | 338 | await state.updateServerVersion(undefined); |
339 | } | 339 | } |
340 | 340 | ||
341 | if (state.serverVersion === config.package.version) return dest.path; | 341 | if (state.serverVersion === config.package.version) return dest.fsPath; |
342 | 342 | ||
343 | if (config.askBeforeDownload) { | 343 | if (config.askBeforeDownload) { |
344 | const userResponse = await vscode.window.showInformationMessage( | 344 | const userResponse = await vscode.window.showInformationMessage( |
345 | `Language server version ${config.package.version} for rust-analyzer is not installed.`, | 345 | `Language server version ${config.package.version} for rust-analyzer is not installed.`, |
346 | "Download now" | 346 | "Download now" |
347 | ); | 347 | ); |
348 | if (userResponse !== "Download now") return dest.path; | 348 | if (userResponse !== "Download now") return dest.fsPath; |
349 | } | 349 | } |
350 | 350 | ||
351 | const releaseTag = config.package.releaseTag; | 351 | const releaseTag = config.package.releaseTag; |
@@ -372,7 +372,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
372 | } | 372 | } |
373 | 373 | ||
374 | await state.updateServerVersion(config.package.version); | 374 | await state.updateServerVersion(config.package.version); |
375 | return dest.path; | 375 | return dest.fsPath; |
376 | } | 376 | } |
377 | 377 | ||
378 | function serverPath(config: Config): string | null { | 378 | function serverPath(config: Config): string | null { |
@@ -383,7 +383,7 @@ async function isNixOs(): Promise<boolean> { | |||
383 | try { | 383 | try { |
384 | const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString(); | 384 | const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString(); |
385 | return contents.indexOf("ID=nixos") !== -1; | 385 | return contents.indexOf("ID=nixos") !== -1; |
386 | } catch (e) { | 386 | } catch { |
387 | return false; | 387 | return false; |
388 | } | 388 | } |
389 | } | 389 | } |
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 747c02db9..722dab756 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts | |||
@@ -91,7 +91,7 @@ export async function download(opts: DownloadOpts) { | |||
91 | // to prevent partially downloaded files when user kills vscode | 91 | // to prevent partially downloaded files when user kills vscode |
92 | // This also avoids overwriting running executables | 92 | // This also avoids overwriting running executables |
93 | const randomHex = crypto.randomBytes(5).toString("hex"); | 93 | const randomHex = crypto.randomBytes(5).toString("hex"); |
94 | const rawDest = path.parse(opts.dest.path); | 94 | const rawDest = path.parse(opts.dest.fsPath); |
95 | const tempFilePath = vscode.Uri.joinPath(vscode.Uri.file(rawDest.dir), `${rawDest.name}${randomHex}`); | 95 | const tempFilePath = vscode.Uri.joinPath(vscode.Uri.file(rawDest.dir), `${rawDest.name}${randomHex}`); |
96 | 96 | ||
97 | await vscode.window.withProgress( | 97 | await vscode.window.withProgress( |
@@ -116,7 +116,7 @@ export async function download(opts: DownloadOpts) { | |||
116 | } | 116 | } |
117 | ); | 117 | ); |
118 | 118 | ||
119 | await vscode.workspace.fs.rename(tempFilePath, opts.dest); | 119 | await vscode.workspace.fs.rename(tempFilePath, opts.dest, { overwrite: true }); |
120 | } | 120 | } |
121 | 121 | ||
122 | async function downloadFile( | 122 | async function downloadFile( |
@@ -127,17 +127,19 @@ async function downloadFile( | |||
127 | httpProxy: string | null | undefined, | 127 | httpProxy: string | null | undefined, |
128 | onProgress: (readBytes: number, totalBytes: number) => void | 128 | onProgress: (readBytes: number, totalBytes: number) => void |
129 | ): Promise<void> { | 129 | ): Promise<void> { |
130 | const urlString = url.toString(); | ||
131 | |||
130 | const res = await (() => { | 132 | const res = await (() => { |
131 | if (httpProxy) { | 133 | if (httpProxy) { |
132 | log.debug(`Downloading ${url.path} via proxy: ${httpProxy}`); | 134 | log.debug(`Downloading ${urlString} via proxy: ${httpProxy}`); |
133 | return fetch(url.path, { agent: new HttpsProxyAgent(httpProxy) }); | 135 | return fetch(urlString, { agent: new HttpsProxyAgent(httpProxy) }); |
134 | } | 136 | } |
135 | 137 | ||
136 | return fetch(url.path); | 138 | return fetch(urlString); |
137 | })(); | 139 | })(); |
138 | 140 | ||
139 | if (!res.ok) { | 141 | if (!res.ok) { |
140 | log.error("Error", res.status, "while downloading file from", url.path); | 142 | log.error("Error", res.status, "while downloading file from", urlString); |
141 | log.error({ body: await res.text(), headers: res.headers }); | 143 | log.error({ body: await res.text(), headers: res.headers }); |
142 | 144 | ||
143 | throw new Error(`Got response ${res.status} when trying to download a file.`); | 145 | throw new Error(`Got response ${res.status} when trying to download a file.`); |
@@ -146,7 +148,7 @@ async function downloadFile( | |||
146 | const totalBytes = Number(res.headers.get('content-length')); | 148 | const totalBytes = Number(res.headers.get('content-length')); |
147 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); | 149 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); |
148 | 150 | ||
149 | log.debug("Downloading file of", totalBytes, "bytes size from", url.path, "to", destFilePath.path); | 151 | log.debug("Downloading file of", totalBytes, "bytes size from", urlString, "to", destFilePath.fsPath); |
150 | 152 | ||
151 | let readBytes = 0; | 153 | let readBytes = 0; |
152 | res.body.on("data", (chunk: Buffer) => { | 154 | res.body.on("data", (chunk: Buffer) => { |
@@ -154,7 +156,7 @@ async function downloadFile( | |||
154 | onProgress(readBytes, totalBytes); | 156 | onProgress(readBytes, totalBytes); |
155 | }); | 157 | }); |
156 | 158 | ||
157 | const destFileStream = fs.createWriteStream(destFilePath.path, { mode }); | 159 | const destFileStream = fs.createWriteStream(destFilePath.fsPath, { mode }); |
158 | const srcStream = gunzip ? res.body.pipe(zlib.createGunzip()) : res.body; | 160 | const srcStream = gunzip ? res.body.pipe(zlib.createGunzip()) : res.body; |
159 | 161 | ||
160 | await pipeline(srcStream, destFileStream); | 162 | await pipeline(srcStream, destFileStream); |
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 902d0ddda..355dd76fe 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts | |||
@@ -159,7 +159,7 @@ export const getPathForExecutable = memoize( | |||
159 | // it is not mentioned in docs and cannot be infered by the type signature... | 159 | // it is not mentioned in docs and cannot be infered by the type signature... |
160 | const standardPath = vscode.Uri.joinPath(vscode.Uri.file(os.homedir()), ".cargo", "bin", executableName); | 160 | const standardPath = vscode.Uri.joinPath(vscode.Uri.file(os.homedir()), ".cargo", "bin", executableName); |
161 | 161 | ||
162 | if (isFile(standardPath.path)) return standardPath.path; | 162 | if (isFileAtUri(standardPath)) return standardPath.fsPath; |
163 | } catch (err) { | 163 | } catch (err) { |
164 | log.error("Failed to read the fs info", err); | 164 | log.error("Failed to read the fs info", err); |
165 | } | 165 | } |
@@ -177,9 +177,17 @@ function lookupInPath(exec: string): boolean { | |||
177 | : [candidate]; | 177 | : [candidate]; |
178 | }); | 178 | }); |
179 | 179 | ||
180 | return candidates.some(isFile); | 180 | return candidates.some(isFileAtPath); |
181 | } | 181 | } |
182 | 182 | ||
183 | async function isFile(path: string): Promise<boolean> { | 183 | async function isFileAtPath(path: string): Promise<boolean> { |
184 | return ((await vscode.workspace.fs.stat(vscode.Uri.file(path))).type & vscode.FileType.File) !== 0; | 184 | return isFileAtUri(vscode.Uri.file(path)); |
185 | } | ||
186 | |||
187 | async function isFileAtUri(uri: vscode.Uri): Promise<boolean> { | ||
188 | try { | ||
189 | return ((await vscode.workspace.fs.stat(uri)).type & vscode.FileType.File) !== 0; | ||
190 | } catch { | ||
191 | return false; | ||
192 | } | ||
185 | } | 193 | } |