How to Ctrl + Click a filename from file links with other characters from VS Code's Console?

Viewed 323

I have file links with line numbers from stack traces in the VS Code console like so:

Traceback (most recent call last):
        3: from my_file.rb:557:in `<main>'
        2: from my_file.rb:366:in `each'
        1: from my_file.rb:372:in `block (2 levels) in process'
my_file.rb:372:in `to_f': wrong number of arguments (given 1, expected 0) (ArgumentError)

When I Ctrl-Click such a link, VSCode tries to open it but returns "No Matching Result", because it sees my_file.rb:372:in as a link target (due to the missing space before in).

VSCode Command Palette

I have to manually press backspace three times to remove :in from the search term and press enter again.

Is there any way to teach VSCode to interpret these file links correctly?

1 Answers

I had the same problem with running tests for Python apps, with the terminal output showing the format filename.py::test_name (similar to your Ruby output), and VS Code failed to highlight/select just the filename.

You can try updating the setting terminal.integrated.wordSeparators to include the : character:

"terminal.integrated.wordSeparators": " ()[]{}',\"`─:",  // <--- Add `:` 

The default value doesn't include the : character, so I think, that's why it doesn't split filename:xxx into its "word" parts. Here's a demo where I try to click on main.py from main.py::test_my_model:

demo effect of adding colon

The setting was introduced in VS Code 1.45:

Control double-click word selection

The new terminal.integrated.wordSeparators setting lets you customize the separator characters used to delimit a word when you double-click in the terminal.

In case it's version- or env-specific, it works on:

  • Visual Studio Code 1.61.2
  • macOS (using CMD + click)
Related