Skip to content

Support ${taskVar:name} variables from problem matcher named capture groups#303362

Open
hediet wants to merge 2 commits intomainfrom
hdieterichs/taskVar-variables
Open

Support ${taskVar:name} variables from problem matcher named capture groups#303362
hediet wants to merge 2 commits intomainfrom
hdieterichs/taskVar-variables

Conversation

@hediet
Copy link
Member

@hediet hediet commented Mar 20, 2026

Fixes #303361

What

Introduces ${taskVar:name} variables that extract named capture groups from a task problem matcher's endsPattern and make them available for variable substitution in launch configurations and other resolved contexts.

How

  1. WatchingProblemCollector.tryFinish() — When the endsPattern matches, matches.groups is extracted into a Map<string, string> and attached to the BackgroundProcessingEnds event.

  2. IProblemCollectorEvent — Extended with an optional capturedVariables field.

  3. TerminalTaskSystem — Listens for capturedVariables in the state change event and registers them via IConfigurationResolverService.contributeVariable() using the taskVar: prefix.

  4. VariableKind.TaskVar — Added to the enum for completeness.

Example

// tasks.json — endsPattern with named capture group
"endsPattern": "  current session url: (?<componentExplorerUrl>.*)"

// launch.json — reference the captured value
"url": "${taskVar:componentExplorerUrl}"

Files changed

File Change
src/vs/workbench/contrib/tasks/common/problemCollectors.ts Extract named groups, extend event
src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts Register captured variables
src/vs/workbench/services/configurationResolver/common/configurationResolver.ts Add TaskVar to VariableKind
src/vs/workbench/services/configurationResolver/test/.../configurationResolverService.test.ts Test for taskVar resolution
.vscode/launch.json Use ${taskVar:componentExplorerUrl} for Component Explorer
.vscode/tasks.json Updated endsPattern with named capture group

Fixes #303361

Introduces \\\ variables that extract named capture groups
from a task problem matcher's endsPattern and make them available for
substitution in launch configurations and other variable-resolved contexts.

Changes:
- WatchingProblemCollector.tryFinish() extracts matches.groups from endsPattern
- IProblemCollectorEvent carries capturedVariables in BackgroundProcessingEnds
- TerminalTaskSystem registers captured variables via contributeVariable()
- VariableKind.TaskVar added to the enum
- Test added for taskVar variable resolution
- .vscode/launch.json updated to use \
Copilot AI review requested due to automatic review settings March 20, 2026 00:57
@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for ${taskVar:name} variables that surface named capture groups from a background task problem matcher’s endsPattern, enabling downstream variable substitution (e.g. in launch configurations) based on values emitted in task output.

Changes:

  • Extend problem collector end events to optionally carry named regex capture groups (matches.groups) as a capturedVariables map.
  • Register captured variables in TerminalTaskSystem as contributed configuration resolver variables under the taskVar: prefix.
  • Add VariableKind.TaskVar and a configuration resolver test validating ${taskVar:...} substitution, plus update workspace .vscode task/launch configs to use the new variable.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/vs/workbench/contrib/tasks/common/problemCollectors.ts Extracts named capture groups from endsPattern matches and propagates them via the problem collector state change event.
src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts Consumes capturedVariables and contributes taskVar:<name> variables to the configuration resolver.
src/vs/workbench/services/configurationResolver/common/configurationResolver.ts Adds TaskVar to VariableKind for taskVar recognition.
src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts Adds test coverage for resolving a contributed taskVar:<name> variable in a configuration object.
.vscode/tasks.json Updates the Component Explorer task endsPattern to include a named capture group for the URL.
.vscode/launch.json Switches Component Explorer launch URLs to ${taskVar:componentExplorerUrl}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ${taskVar:name} variables from problem matcher named capture groups

4 participants