mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
fix: avoid doubling cargo args in runnables
This commit is contained in:
parent
4af21ffb02
commit
b50fc06e0d
1 changed files with 9 additions and 8 deletions
|
@ -1,8 +1,7 @@
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import * as toolchain from "./toolchain";
|
|
||||||
import type { Config } from "./config";
|
import type { Config } from "./config";
|
||||||
import { log } from "./util";
|
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
|
// 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.
|
// our configuration should be compatible with it so use the same key.
|
||||||
|
@ -142,14 +141,16 @@ async function cargoToExecution(
|
||||||
if (definition.type === TASK_TYPE) {
|
if (definition.type === TASK_TYPE) {
|
||||||
// Check whether we must use a user-defined substitute for cargo.
|
// Check whether we must use a user-defined substitute for cargo.
|
||||||
// Split on spaces to allow overrides like "wrapper cargo".
|
// Split on spaces to allow overrides like "wrapper cargo".
|
||||||
const cargoPath = await toolchain.cargoPath();
|
const cargoCommand = definition.overrideCargo?.split(" ") ?? [definition.command];
|
||||||
const cargoCommand = definition.overrideCargo?.split(" ") ?? [cargoPath];
|
|
||||||
|
|
||||||
const args = [definition.command].concat(definition.args ?? []);
|
const definitionArgs = expectNotUndefined(
|
||||||
const fullCommand = [...cargoCommand, ...args];
|
definition.args,
|
||||||
const processName = unwrapUndefinable(fullCommand[0]);
|
"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,
|
cwd: definition.cwd,
|
||||||
env: definition.env,
|
env: definition.env,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue