microsoft / vscode-docs

Public documentation for Visual Studio Code
http://code.visualstudio.com/docs
Other
5.73k stars 4.68k forks source link

Wrapped Lines Break Custom Problem Matcher #6851

Open LethiferousMoose opened 1 year ago

LethiferousMoose commented 1 year ago

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

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....

meganrogge commented 1 year ago

Thanks for the information. I'm going to close this because as you said, seems like a duplicate of https://github.com/microsoft/vscode/issues/152634

LethiferousMoose commented 1 year ago

@meganrogge Should I log an issue around the documentation not being very clear on the multi-line errors or what is the best way to have that updated with a better example and/or explanation?