diff options
| author | David Barsky <me@davidbarsky.com> | 2024-06-13 11:08:57 -0400 |
|---|---|---|
| committer | David Barsky <me@davidbarsky.com> | 2024-06-13 11:08:58 -0400 |
| commit | c2843be1bb75a3aae409b7e4fb5f6379ecb6e3cd (patch) | |
| tree | 9aef3778f11870b410a3b85a4509b419e3696301 | |
| parent | a97aef8466688d0d14fea1c311fa8db24173b5e1 (diff) | |
| download | rust-c2843be1bb75a3aae409b7e4fb5f6379ecb6e3cd.tar.gz rust-c2843be1bb75a3aae409b7e4fb5f6379ecb6e3cd.zip | |
fix: avoid doubling cargo args in runnables
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/tasks.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tools/rust-analyzer/editors/code/src/tasks.ts b/src/tools/rust-analyzer/editors/code/src/tasks.ts index c28a919231b..c14f7a1175c 100644 --- a/src/tools/rust-analyzer/editors/code/src/tasks.ts +++ b/src/tools/rust-analyzer/editors/code/src/tasks.ts @@ -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, }); |
