Open jaredp opened 3 years ago
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.
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 https://github.com/microsoft/vscode/issues/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.
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 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
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.
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
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.
can we get authority use extension api
Steps to Reproduce:
/my/file/path.js
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