Search code examples
regexvisual-studio-codevscode-tasks

Visual Studio Code problem matcher not working with custom output


I'm trying to get VS Code working with custom output. I've created a batch file which prints out:

warning:main.asm(5):Something is wrong
ERROR:main.asm(2):Something else is wrong

But when I run the following task:

"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "${workspaceFolder}\\build.bat",
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "problemMatcher":{
            "pattern":[
                {
                    "regexp": "^.*:(.*)\\(\\d+\\):(.+)$",
                    "file": 1,
                    "line": 2,
                    "message": 3,
                    "location": 0
            }]
        }
    }
]

I get the output that I'm expecting but I don't get any errors in the problems window. Any ideas?


Solution

  • Your regex isn't quite correct - since the parens around \\(\\d+\\) are escaped, it's not actually a capturing group. With an additional pair or parens it works for me:

    "regexp": "^.*:(.*)\\((\\d+)\\):(.+)$"