Automatically jump to error after compilation in Visual Studio Code (custom language)

445 views Asked by At

I have created a custom language plugin for VS Code.
Also I created a task with a custom problem matcher:

"problemMatcher": {
            "owner": "customlang",
            "fileLocation": ["relative", "./"],
            "severity": "error",
            "pattern": {
                "regexp": "^(.*)<(\\d+)>\\s:(.*):(.*)",
                "file": 1,
                "line": 2,
                "message": 4
            }
        }

This works fine and reports errors correctly in the Problems tab at the bottom.
However, I have to manually click the error to jump to it.

Is there a way to automatically jump to an error, once there is one?
(in this language, there are never multiple errors at once)

1

There are 1 answers

0
Llewey On

As far as I know, there is no way to do this using the built in tasks.

You can open an issue requesting this feature at https://www.github.com/microsoft/vscode/issues/new

If you use your extension to do the build, though, instead of tasks, you can have your extension execute the build (for example, if it was typescript you would use node to execute tsc) and you would process the output yourself to create a "diagnostic" (i.e. problems) and you could then jump to it.

But I don't think tasks can automatically jump to them and your extension can't see the problems reported by the task.