microsoft / vscode

Visual Studio Code

Home Page:https://code.visualstudio.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

gerane opened this issue · comments

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
.

Duplicate of #1397 since this issue is an implementation detail of that issue.

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!