Skip to content

Feature Request: dynamically set "owner" for Watcher\background Tasks . #22242

@gerane

Description

@gerane

When using a watcher task to run actions, sometimes you may only want to run an action against that single file instead of the entire project. The problem is that if you have existing matched problems, this will erase existing problem matches since they share the same "owner" property. This issue is referencing this problem #1397

For these types of tasks it would be beneficial to allow the "owner" property to be dynamically set via matcher. One way this could be achieved is via a Pattern Matcher. Using the tsc example from the Documentation it might look something like below.

{
    "version": "0.1.0",
    "command": "tsc",
    "suppressTaskName": true,
    "tasks": [
        {
            "taskName": "watch",
            "args": ["--watch"],
            "isBackground": true,
            "problemMatcher": {
                "fileLocation": "relative",
                "pattern": {
                    "regexp": "^([^\\s].*)\\((\\d+|\\,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
                    "file": 1,
                    "location": 2,
                    "severity": 3,
                    "code": 4,
                    "message": 5,
                    "owner": 1
                },
                "watching": {
                    "activeOnStart": true,
                    "beginsPattern": "^\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? - File change detected\\. Starting incremental compilation\\.\\.\\.",
                    "endsPattern": "^\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? - Compilation complete\\. Watching for file changes\\."
                }
            }
        }
    ]
}

This just sets the "owner" as the matched File and removed the "owner" property from "problemMatcher". This would make it where only problems matched to that file would be cleared when the watcher triggers again.

EDIT: Adding a few gifs showing an example use case.

Pester Unit Tests - Watcher Runs all Tests

watchproject

Pester Unit Tests - Watcher Runs only Tests for edited file

singlererun
.

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)feature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiestasksTask system issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions