Problem
When a background task's endsPattern matches terminal output, VS Code only uses the match as a signal that background processing has ended. Any data captured by the regex (e.g., a dynamically assigned port or URL) is discarded.
This means launch configurations that depend on dynamic values from task output (like a server URL) must hardcode values or rely on workarounds.
Proposed Solution
Introduce ${taskVar:name} variables that capture named groups from a problem matcher's endsPattern regex and make them available for substitution in launch configurations (and anywhere else variables are resolved).
How it works
-
A task's problem matcher endsPattern uses a named capture group:
"endsPattern": " current session url: (?<componentExplorerUrl>.*)"
-
When the pattern matches, the named group values are extracted and registered as contributed variables.
-
A launch configuration references the captured value:
"url": "${taskVar:componentExplorerUrl}"
Naming convention
The ${taskVar:name} syntax follows VS Code's existing ${name:arg} convention (like ${env:PATH}, ${config:setting}, ${command:id}).
Implementation
WatchingProblemCollector.tryFinish() extracts matches.groups from the endsPattern match
IProblemCollectorEvent carries captured variables in the BackgroundProcessingEnds event
TerminalTaskSystem registers captured variables via IConfigurationResolverService.contributeVariable()
VariableKind.TaskVar added for completeness
Example
Problem
When a background task's
endsPatternmatches terminal output, VS Code only uses the match as a signal that background processing has ended. Any data captured by the regex (e.g., a dynamically assigned port or URL) is discarded.This means launch configurations that depend on dynamic values from task output (like a server URL) must hardcode values or rely on workarounds.
Proposed Solution
Introduce
${taskVar:name}variables that capture named groups from a problem matcher'sendsPatternregex and make them available for substitution in launch configurations (and anywhere else variables are resolved).How it works
A task's problem matcher
endsPatternuses a named capture group:When the pattern matches, the named group values are extracted and registered as contributed variables.
A launch configuration references the captured value:
Naming convention
The
${taskVar:name}syntax follows VS Code's existing${name:arg}convention (like${env:PATH},${config:setting},${command:id}).Implementation
WatchingProblemCollector.tryFinish()extractsmatches.groupsfrom theendsPatternmatchIProblemCollectorEventcarries captured variables in theBackgroundProcessingEndseventTerminalTaskSystemregisters captured variables viaIConfigurationResolverService.contributeVariable()VariableKind.TaskVaradded for completenessExample