Telling running VS Code session to jump to filename/line_number

In IntelliJ/Rust, an external program can cause the IDE to jump to a particular line number / file by executing

launch-idea --line LINE_NUMBER FILE_NAME

this is useful if stackframes are displayed outside of the IDE, and we want "click on it" -> IDE jumps to right line number / file name.

In VS code, is there something similar? In particular, I want some command line option that let me instruct the existing / running VS Code session to jump to a particular file / line.

Try opening FILE_NAME:LINE_NUMBER. That trick works for Sublime.

I believe the question you answered is:

  • Suppose I have an application that prints out strings.
  • What format should it print out a (filename, line_number) combo in the terminal so that if the user clicke don it inside the VS Code IDE, it will cause the IDE to jump to the right filename / line number combo.

The question I meant to ask is:

  • I am writing an OpenGL app.
  • Inside my OpenGL app, I have button-like thihngs.
  • When the user clicks on a 'button', I want it to call some shell command.
  • Calling this shell command should cause the IDE to jump to a filename / line_number combo.

In IntelliJ, I can use the launch-idea --line ... technique. Is there something similar for VS Code ?

The 'XY problem here is that I have an Err type that uses the backtrace-rs datatype to capture a Backtrace inside the Result<.., Err>. Then, at a later point, when displaying the Err (in OpenGL), I can display the backtrace of filename/line_number. Now, when I click on this (inside OpenGL), I want to cause this to run some shell command that tells the current active VS Code to jump to a particular file name / line number.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.