mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Merge #10093
10093: fix: Remove incorrectly filtering VS Code cargo task execution resolution by scope r=oeed a=oeed This fixes #9093 introduced by #8995. A filter was present on the function that adds the execution definition to Cargo tasks. This would mean Cargo tasks defined in workspaces (i.e. `.code-workspace` files) would not be given an execution, leading to a `There is no task provider registered for tasks of type "cargo".` error as descibed in #9093. I have made a minimum reproduction setup [here](https://github.com/oeed/ra-workspace). This PR essentially removes that check. The `if (scope) { ... }` is to handle the case where `task.scope === undefined` using a deprecated constructor. I'm not sure if that is ever likely to occur and can remove if not needed. There is some discussion about whether it's necessary to filter the tasks before building them. From my understanding, it shouldn't be needed as we should provide an execution for all `cargo` tasks; but I'm not overly familiar with VS Code internals so I could be wrong. For more info please see [the discussion](https://github.com/rust-analyzer/rust-analyzer/pull/8995#issuecomment-908920395) on #8995 Co-authored-by: Oliver Cooper <oliver.cooper@me.com>
This commit is contained in:
commit
22162aa363
1 changed files with 5 additions and 9 deletions
|
@ -58,21 +58,15 @@ class CargoTaskProvider implements vscode.TaskProvider {
|
|||
|
||||
if (definition.type === TASK_TYPE && definition.command) {
|
||||
const args = [definition.command].concat(definition.args ?? []);
|
||||
if (isWorkspaceFolder(task.scope)) {
|
||||
return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
|
||||
}
|
||||
return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function isWorkspaceFolder(scope?: any): scope is vscode.WorkspaceFolder {
|
||||
return (scope as vscode.WorkspaceFolder).name !== undefined;
|
||||
}
|
||||
|
||||
export async function buildCargoTask(
|
||||
target: vscode.WorkspaceFolder,
|
||||
scope: vscode.WorkspaceFolder | vscode.TaskScope | undefined,
|
||||
definition: CargoTaskDefinition,
|
||||
name: string,
|
||||
args: string[],
|
||||
|
@ -117,7 +111,9 @@ export async function buildCargoTask(
|
|||
|
||||
return new vscode.Task(
|
||||
definition,
|
||||
target,
|
||||
// scope can sometimes be undefined. in these situations we default to the workspace taskscope as
|
||||
// recommended by the official docs: https://code.visualstudio.com/api/extension-guides/task-provider#task-provider)
|
||||
scope ?? vscode.TaskScope.Workspace,
|
||||
name,
|
||||
TASK_SOURCE,
|
||||
exec,
|
||||
|
|
Loading…
Reference in a new issue