Skip to content

Commit 1db22ab

Browse files
committed
fix: avoid doubling cargo args in runnables
1 parent 4af21ff commit 1db22ab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

editors/code/src/tasks.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22
import * as toolchain from "./toolchain";
33
import type { Config } from "./config";
44
import { log } from "./util";
5-
import { unwrapUndefinable } from "./undefinable";
5+
import { expectNotUndefined, unwrapUndefinable } from "./undefinable";
66

77
// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
88
// our configuration should be compatible with it so use the same key.
@@ -142,14 +142,16 @@ async function cargoToExecution(
142142
if (definition.type === TASK_TYPE) {
143143
// Check whether we must use a user-defined substitute for cargo.
144144
// Split on spaces to allow overrides like "wrapper cargo".
145-
const cargoPath = await toolchain.cargoPath();
146-
const cargoCommand = definition.overrideCargo?.split(" ") ?? [cargoPath];
145+
const cargoCommand = definition.overrideCargo?.split(" ") ?? [definition.command];
147146

148-
const args = [definition.command].concat(definition.args ?? []);
149-
const fullCommand = [...cargoCommand, ...args];
150-
const processName = unwrapUndefinable(fullCommand[0]);
147+
const definitionArgs = expectNotUndefined(
148+
definition.args,
149+
"args were not provided via runnables; this is a bug.",
150+
);
151+
const args = [...cargoCommand.slice(1), ...definitionArgs];
152+
const processName = unwrapUndefinable(cargoCommand[0]);
151153

152-
return new vscode.ProcessExecution(processName, fullCommand.slice(1), {
154+
return new vscode.ProcessExecution(processName, args, {
153155
cwd: definition.cwd,
154156
env: definition.env,
155157
});

0 commit comments

Comments
 (0)