aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorveetaha <[email protected]>2020-05-23 02:58:22 +0100
committerveetaha <[email protected]>2020-05-31 01:10:23 +0100
commit030d78345fa79af07f8ebd89a9d244576fac992b (patch)
tree935da29fbb0418e8158e06f227f238bda13ee55f /editors/code
parent5f7225446e75509ae0d971a6f3e2b9d3e37d6f2a (diff)
Fix invoking cargo without consulting CARGO or standard installation paths
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/cargo.ts4
-rw-r--r--editors/code/src/tasks.ts7
2 files changed, 7 insertions, 4 deletions
diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts
index a55b2f860..46cd3d777 100644
--- a/editors/code/src/cargo.ts
+++ b/editors/code/src/cargo.ts
@@ -126,8 +126,8 @@ export class Cargo {
126 } 126 }
127} 127}
128 128
129// Mirrors `ra_env::get_path_for_executable` implementation 129// Mirrors `ra_toolchain::cargo()` implementation
130function getCargoPathOrFail(): string { 130export function getCargoPathOrFail(): string {
131 const envVar = process.env.CARGO; 131 const envVar = process.env.CARGO;
132 const executableName = "cargo"; 132 const executableName = "cargo";
133 133
diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts
index 1366c76d6..c22d69362 100644
--- a/editors/code/src/tasks.ts
+++ b/editors/code/src/tasks.ts
@@ -1,4 +1,5 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import { getCargoPathOrFail } from "./cargo";
2 3
3// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and 4// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
4// our configuration should be compatible with it so use the same key. 5// our configuration should be compatible with it so use the same key.
@@ -24,6 +25,8 @@ class CargoTaskProvider implements vscode.TaskProvider {
24 // set of tasks that always exist. These tasks cannot be removed in 25 // set of tasks that always exist. These tasks cannot be removed in
25 // tasks.json - only tweaked. 26 // tasks.json - only tweaked.
26 27
28 const cargoPath = getCargoPathOrFail();
29
27 return [ 30 return [
28 { command: 'build', group: vscode.TaskGroup.Build }, 31 { command: 'build', group: vscode.TaskGroup.Build },
29 { command: 'check', group: vscode.TaskGroup.Build }, 32 { command: 'check', group: vscode.TaskGroup.Build },
@@ -46,7 +49,7 @@ class CargoTaskProvider implements vscode.TaskProvider {
46 `cargo ${command}`, 49 `cargo ${command}`,
47 'rust', 50 'rust',
48 // What to do when this command is executed. 51 // What to do when this command is executed.
49 new vscode.ShellExecution('cargo', [command]), 52 new vscode.ShellExecution(cargoPath, [command]),
50 // Problem matchers. 53 // Problem matchers.
51 ['$rustc'], 54 ['$rustc'],
52 ); 55 );
@@ -80,4 +83,4 @@ class CargoTaskProvider implements vscode.TaskProvider {
80export function activateTaskProvider(target: vscode.WorkspaceFolder): vscode.Disposable { 83export function activateTaskProvider(target: vscode.WorkspaceFolder): vscode.Disposable {
81 const provider = new CargoTaskProvider(target); 84 const provider = new CargoTaskProvider(target);
82 return vscode.tasks.registerTaskProvider(TASK_TYPE, provider); 85 return vscode.tasks.registerTaskProvider(TASK_TYPE, provider);
83} \ No newline at end of file 86}