Skip to content

Wrapped Lines Break Custom Problem Matcher #6851

Open
@LethiferousMoose

Description

@LethiferousMoose

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.84.2
  • OS Version: Windows 10

I saw this issue crop up on your GitHub for other problem matchers, but tbh it was super unclear if this was supposed to be fixed or not. microsoft/vscode#32042 makes it sound fixed, but then we have microsoft/vscode#152634 which sounds very similar.

Steps to Reproduce:

  1. Create a dummy script the outputs long lines (like replicating the output from running tests with dotnet test)
  2. Associate that script to a task.
  3. Create a problem matcher that attempts to get the error message, fully qualified test name, and line number.
  4. Problem matcher consistently fails when the terminal is not scaled large enough for the fully qualified class test (method) name to fit on one line, but seems to work "most" of the time when the terminal large enough and does not wrap the lines.

Sample Task

{
    "windows": {
        "options": {
            "shell": {
                "executable": "pwsh.exe",
                "args": [
                    "-NoProfile",
                    "-ExecutionPolicy",
                    "Bypass",
                    "-Command"
                ]
            }
        }
    },
    "label": "Test MultiLine",
    "type": "shell",
    "command": "${workspaceFolder}/TestMultiLine.ps1",
    "group": {
        "kind": "test",
        "isDefault": true
    },
    "problemMatcher": {
        "fileLocation": ["absolute"],
        "severity": "error",
        "pattern": [
            {
                "regexp": "^\\s+(Assert.*)$",
                "message": 1
            },
            {
                "regexp": "^\\s+Stack Trace:$"
            },
            {
                "regexp": "^\\s+at\\s+(.*)\\s+in\\s+(.*):line\\s+(\\d+)\\s*$",
                "file": 2,
                "line": 3
            }
        ]
    }
}

TestMultiLine.ps1

Write-Output '  Failed MethodNameThatSeemsToGoOnForever [6 ms]'
Write-Output '  Error Message:'
Write-Output '   Assert.ThrowsException failed. No exception thrown. ThisExceptionHappensSometimes() exception was expected.'
Write-Output '  Stack Trace:'
Write-Output '     at Hello.World.This.IsAVeryLongClassNameWithAnEquallyLong.MethodNameThatSeemsToGoOnForever() in C:\Also\The Path To The File Is Also\Very Large\Which\Means.This\Will\LikelyWrapForMostPeople.cs:line 110'

Footnote

I spent like 6 hours trying to understand what the heck was going on, so some clarity on this would be wonderful.

As a side note the documentation on multi-line problem matcher patterns is super vague, from I've been able to discern mostly by trial, error, and searching VS Code GitHub. Is that when you have a multi-line pattern, you seemingly need to match every line in between, even if you do not care about those lines.

As far as I can tell nothing mentions that explicitly and the example in the docs Defining a multiline problem matcher "works" because the multi-lines they are matching are immediately after the first line they are matching. The docs do say This way you define a pattern per each line you want to match, but that's also not super obvious because I DON'T want to match them, I don't care about those lines. If someone could also confirm this that would be nice or I can log a documentation issue to give some better clarity on this so other people don't spend their entire night playing with regexes that work and consistently don't work in VS Code problem matchers....

Metadata

Metadata

Assignees

Labels

doc-bugout of date, inaccurate, confusing contenthelp wantedIssues identified as good community contribution opportunities

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions