Auto merge of #17407 - davidbarsky:david/fix-17402, r=Veykril

fix: avoid doubling cargo args in runnables

Fixes #17402.

Sorry about this—I think I missed up the rebase!
This commit is contained in:
bors 2024-06-13 15:34:29 +00:00
commit e059feadef

View file

@ -1,8 +1,7 @@
import * as vscode from "vscode";
import * as toolchain from "./toolchain";
import type { Config } from "./config";
import { log } from "./util";
import { unwrapUndefinable } from "./undefinable";
import { expectNotUndefined, unwrapUndefinable } from "./undefinable";
// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
// our configuration should be compatible with it so use the same key.
@ -142,14 +141,16 @@ async function cargoToExecution(
if (definition.type === TASK_TYPE) {
// Check whether we must use a user-defined substitute for cargo.
// Split on spaces to allow overrides like "wrapper cargo".
const cargoPath = await toolchain.cargoPath();
const cargoCommand = definition.overrideCargo?.split(" ") ?? [cargoPath];
const cargoCommand = definition.overrideCargo?.split(" ") ?? [definition.command];
const args = [definition.command].concat(definition.args ?? []);
const fullCommand = [...cargoCommand, ...args];
const processName = unwrapUndefinable(fullCommand[0]);
const definitionArgs = expectNotUndefined(
definition.args,
"args were not provided via runnables; this is a bug.",
);
const args = [...cargoCommand.slice(1), ...definitionArgs];
const processName = unwrapUndefinable(cargoCommand[0]);
return new vscode.ProcessExecution(processName, fullCommand.slice(1), {
return new vscode.ProcessExecution(processName, args, {
cwd: definition.cwd,
env: definition.env,
});