Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode remote: Interpolate environment variable to build editor link scheme? #509

Open
coezbek opened this issue Dec 3, 2021 · 2 comments

Comments

@coezbek
Copy link

coezbek commented Dec 3, 2021

I am using Visual Studio Code under WSL remote. To build the URL for the editor link scheme I need to access an environment variable for the current distro being used. This works as an initializer, but I was hoping to contribute a patch to the KNOWN_EDITORS.

if defined?(BetterErrors)
  BetterErrors.editor = "vscode://vscode-remote/wsl+#{ENV['WSL_DISTRO_NAME']}%{file_unencoded}:%{line}"
end

Discussion on SO for building the URL path for VS code remote: https://stackoverflow.com/questions/66582696/url-for-opening-vscode-in-file-in-wsl-workspace?noredirect=1#comment124115062_66582696

@RobinDaugherty
Copy link
Member

Thanks for this @coezbek! I see that you added it to the wiki page already, which is what I would have recommended rather than adding to KNOWN_EDITORS, especially since your case uses an environment variable to assemble the URL. However, I would also recommend that you change your snippet to only be executed when that environment variable is set. i.e.

if defined?(BetterErrors) && (distro_name = ENV['WSL_DISTRO_NAME'])
  BetterErrors.editor = "vscode://vscode-remote/wsl+#{distro_name}%{file_unencoded}:%{line}"
end

@coezbek
Copy link
Author

coezbek commented Dec 12, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants