diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2022-10-08 23:18:11 +0100 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2022-10-08 23:25:13 +0100 |
| commit | 5bbfea03ccada14bbaca6df6c0ef3760ac44a9a5 (patch) | |
| tree | 63f1d3a2957edc137970f90ceadb5ee675816d53 /editors/code/src/commands.ts | |
| parent | 61504c8d951c566eb03037dcb300c96f4bd9a8b6 (diff) | |
| download | rust-5bbfea03ccada14bbaca6df6c0ef3760ac44a9a5.tar.gz rust-5bbfea03ccada14bbaca6df6c0ef3760ac44a9a5.zip | |
fix: in VSCode, correctly resolve relative paths to errors
VS Code problem matcher are restricted to be static "regexes". You can't
create a problem matcher dynamically, and you can't use custom code in
lieu of problem matcher.
This creates a problem for rust/cargo compiler errors. They use paths
relative to the root of the Cargo workspace, but VS Code doesn't
necessary know where that root is.
Luckily, there's a way out: our current problem matcher is defined like
this:
"fileLocation": [ "autoDetect", "${workspaceRoot}" ],
That means that relative pahts would be resoleved relative to workspace
root. VS Code allows to specify a command inside `${}`. So we can plug
custom logic there to fetch Cargo's workspace root!
And that's exactly what this PR is doing!
Diffstat (limited to 'editors/code/src/commands.ts')
| -rw-r--r-- | editors/code/src/commands.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index b9ad525e361..6b10073aa86 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -842,6 +842,7 @@ export function run(ctx: Ctx): Cmd { item.detail = "rerun"; prevRunnable = item; const task = await createTask(item.runnable, ctx.config); + ctx.cargoWorkspaceRootForCurrentRun = item.cargoWorkspaceRoot; return await vscode.tasks.executeTask(task); }; } @@ -946,3 +947,6 @@ export function linkToCommand(ctx: Ctx): Cmd { } }; } +export function getCargoWorkspaceDir(ctx: Ctx): Cmd { + return async () => ctx.cargoWorkspaceRootForCurrentRun; +} |
