C++ custom problem matchers in VS Code not highlighting file paths

166 Views Asked by At

I have a bunch of custom build tasks in VS Code and I want a custom problem matcher for the C++ ones.

So I decided to take the default problem matcher example in VS Code docs (https://code.visualstudio.com/Docs/editor/tasks#_defining-a-problem-matcher) and modified it slightly.

"problemMatcher": {
        "fileLocation": ["relative", "${workspaceFolder}"],
        "pattern": {
          "regexp": "^(\\.\\.\\/+)(.*):(\\d+):(\\d+):\\s+(.*):\\s+(.*)$",
          "file": 2,
          "line": 3,
          "column": 4,
          "severity": 5,
          "message": 6
        }

My error messages have the following structure:

../../../module/src/module/specific/File.cpp:155:31: error: errorMessage

The three directory-up instructions (../../../) bring me back to ${workspaceFolder}. So the idea was to use the second capture group as a relative path from my workspace folder to follow up to the file.

Unfortunately, the file path does not highlight and it doesn't tell me to Ctrl+click to follow the message. I double checked the regex on https://regexr.com/ and it seems to be correct. I tried using the the default problem matcher too, without any luck.

This is the full build task:

{
      "label": "build_c++",
      "type": "shell",
      "command": "${workspaceFolder}/build_command",
      "problemMatcher": [ {
        "fileLocation": ["relative", "${workspaceFolder}"],
        "pattern": {
          "regexp": "^(\\.\\.\\/+)(.*):(\\d+):(\\d+):\\s+(.*):\\s+(.*)$",
          "file": 2,
          "line": 3,
          "column": 4,
          "severity": 5,
          "message": 6
        }
      }],
      "group": {
        "kind": "build",
        "isDefault": true 
      }
},

Any ideas?

0

There are 0 best solutions below