BetterErrors/better_errors

VS Code looks not accept encode editor url

smoothdvd opened this issue · 2 comments

I use following code to open rb file in VS Code:

if defined? BetterErrors
    # Force all developers on this project to use VS Code, even if they prefer something else.
    BetterErrors.editor = 'vscode://file%<file>s:%<line>s'
end

But VS Code need url like "vscode://file/foo/bar.rb:1", not "vscode://file%2Ffoo%2Fbar.rb:1"

Read the source code, I just know I can setup editor using proc.
Now I can open the file by VS Code with following code:

In config/environments/development.rb, just add:

if defined? BetterErrors
  BetterErrors.editor = proc { |file, line| "vscode://file#{file}:#{line}" }
end

@RobinDaugherty I think we can add this to wiki.

Thanks, I've updated the wiki. But I highly recommend using the EDITOR variable, rather than hard-coding it.

If you come across this in a search, please use the instructions on the wiki, which will be up-to-date, instead of the snippet above.