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

Allow to open vscode:// urls in remote #4779

Open
jaredp opened this issue Mar 28, 2021 · 6 comments
Open

Allow to open vscode:// urls in remote #4779

jaredp opened this issue Mar 28, 2021 · 6 comments
Labels
feature-request Request for new features or functionality ssh Issue in vscode-remote SSH
Milestone

Comments

@jaredp
Copy link

jaredp commented Mar 28, 2021

  • VSCode Version: 1.54.3, Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
  • Local OS Version: macOS Catalina 10.15.7 (19H524)
  • Remote OS Version: Ubuntu 20.04.1 LTS
  • Remote Extension/Connection Type: SSH

Steps to Reproduce:

  1. Open a project in VSCode remote that has a file at absolute path /my/file/path.js
  2. Click on a link (in Chrome, on Mac machine running vscode) with url "vscode://file/my/file/path.js"
  3. Get error modal in open VSCode window with title "Path does not exist", body: "The path '/my/file/path.js' does not seem to exist anymore on disk."

Does this issue occur when you try this locally?: No
Does this issue occur when you try this locally and all extensions are disabled?: No

This is following the vscode:// schema feature described in https://code.visualstudio.com/docs/editor/command-line#_opening-vs-code-with-urls

@chrmarti
Copy link
Contributor

You'd need a vscode-remote://.../my/file/path.js URL. The difficulty is the authority part (...), that is internal to the Remote-SSH extension.

@chrmarti chrmarti added the ssh Issue in vscode-remote SSH label Mar 29, 2021
@jaredp
Copy link
Author

jaredp commented Mar 29, 2021

I can figure out the ... part, but Chrome is giving me Failed to launch 'vscode-remote://ssh+devserver/my/file/path' because the scheme does not have a registered handler.

When I try vscode://vscode-remote/ssh-remote+devserver/my/file/path, I think I run into microsoft/vscode#108257.

However, vscode://file/my/file/path.js does route to the right vscode remote window, whose workspace root is /my/file on the remote host. By comparison vscode://file/other/file/path.js (outside the vscode remote window's workspace root) tries to open the file from the local disk in a new window.

So it looks like vscode's already routing the open-file request to the right window/workspace. Current behavior is broken because vscode's confused as to whether it's trying to open remote or local, and will thus always error.

@bpasero bpasero changed the title vscode:// urls give error "Path does not exist" Allow to open vscode:// urls in remote Mar 30, 2021
@bpasero bpasero added the feature-request Request for new features or functionality label Mar 30, 2021
@bpasero bpasero removed their assignment Mar 30, 2021
@Timmmm
Copy link

Timmmm commented Aug 19, 2022

This appears to be solved now, however the URL schema is still completely undocumented and as far as I can tell there's no way to discover it from existing open files.

I eventually gave up trying to figure it out and just looked at what other people have done.

It seems to be:

  • vscode://vscode-remote/wsl+CONTAINER_NAME/path/to/file
  • vscode://vscode-remote/ssh-remote+[USER@]HOST[:PORT]/path/to/file:ROW:COL

Note the row and column numbers are required for files, otherwise it assumes it is a directory and creates a new instance of VSCode. If you just add :1:1 unconditionally then it won't open folders successfully so unfortunately you do need to know in advance if the target is a file or a folder. Also if you do open a folder it replaces an existing instance of VSCode rather than opening a new one.

So yeah it basically doesn't work very well for folders but it works for files!

@alejoar
Copy link

alejoar commented Oct 12, 2022

This appears to be solved now, however the URL schema is still completely undocumented and as far as I can tell there's no way to discover it from existing open files.

I eventually gave up trying to figure it out and just looked at what other people have done.

It seems to be:

  • vscode://vscode-remote/wsl+CONTAINER_NAME/path/to/file
  • vscode://vscode-remote/ssh-remote+[USER@]HOST[:PORT]/path/to/file:ROW:COL

Note the row and column numbers are required for files, otherwise it assumes it is a directory and creates a new instance of VSCode. If you just add :1:1 unconditionally then it won't open folders successfully so unfortunately you do need to know in advance if the target is a file or a folder. Also if you do open a folder it replaces an existing instance of VSCode rather than opening a new one.

So yeah it basically doesn't work very well for folders but it works for files!

This worked for me when using locatorJS

@pjeby
Copy link

pjeby commented Apr 28, 2023

Additional bit of info: you can get the remote to open in a new window by adding ?windowId=_blank to the end of the URL.

@markNZed
Copy link

markNZed commented Dec 6, 2023

I would like to open links on a remote dev container (docker container) No doubt, if this is possible, it requires something magical in the URL as there is an SSH to the remote machine and then a connection to the remote container. Any help with this is much appreciated - ideally I want a link in a MD file to open another MD file in a new tab (I do not want to launch a new VSCode instance). Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

8 participants
@markNZed @jaredp @Timmmm @bpasero @pjeby @alejoar @chrmarti and others