Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to jump to build error in Visual Studio Code?

I'm using Visual Studio Code (Version 1.8.1) on Linux. When there is a build error and I click on the line that contains the error it doesn't jump to the corresponding line in the code. Is there a way to make Visual Studio Code behave the same as standard Visual Studio?

like image 286
Etay Meiri Avatar asked Jan 25 '17 12:01

Etay Meiri


2 Answers

Did you build your code in TERMINAL window of Visual Studio Code? If so, press down the "Ctrl" key and move the mouse cursor to the filename and line number such as "/home/..../xxx.cpp:123" in the error line, then you can click on it to jump to the corresponding line in the code

It works for me.

like image 57
fengliutie Avatar answered Oct 01 '22 00:10

fengliutie


Have you defined a problem matcher in your tasks.json? There are several built-in ones that can simply be referenced, for instance "problemMatcher": ["$tsc"] will work for TypeScript.

The docs also contain an example for a custom problem matcher for C++:

"problemMatcher": {
    "owner": "cpp",
    "fileLocation": ["relative", "${workspaceRoot}"],
    "pattern": {
        "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
        "file": 1,
        "line": 2,
        "column": 3,
        "severity": 4,
        "message": 5
    }
}

If there's no built-in matcher for the language you're using, you shoulds still be able to find one with a bit of searching if it's moderately popular.

like image 27
Gama11 Avatar answered Oct 01 '22 01:10

Gama11