How to open file path within code comment in vscode?

Viewed 437

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?

1 Answers

You can use 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"
      }
    ]
  }
Related