slow_mohammud
slow_mohammud

Reputation: 87

How to open file path within code comment in vscode?

I have some generated codes which contain comments like // #line 56"/home/alan/quicker/painful/Worker.actor.cpp"

Is it possible for vscode or any vscode extension to open the file path and jump to the corresponding line as described in this comment with just one simple mouse click?

Upvotes: 5

Views: 1999

Answers (1)

rioV8
rioV8

Reputation: 28783

You can use an extension I made: HTML Related Links

This tool allows you to extract file path and line/char positions and open the file there. The file links are in a separate view of the explorer bar.

If you also have relative paths make a second entry.

You can make global links but also scope them to a languageId. Here I have chosen cpp

"html-related-links.include": {
    "cpp": [
      {
        "find": "// #line (\d+)\"(/[^\"])\"",
        "filePath": "$2",
        "isAbsolutePath": true,
        "lineNr": "$1"
      }
    ]
  }

Upvotes: 2

Related Questions