How can an extension obtain remote URL of file in currently connected remote server?

Viewed 233

I'm writing an extension targeted for VSCode Remote environment. In this setup, one extension (UI extension) runs in client and another (workspace extension) runs in remote server.

Now, here's a question - is there any way to generate an URL that can be used by UI extension to access file on the server?

I know I can use vscode-remote://ssh-remote+<hostname>/file/on/server syntax to express this type of remote URL, but the issue here is that I cannot find any way for extension to discover one. Using vscode.Uri.file() API only generates file: URL, which is meaningless for UI extension running in client environment.

Since vscode-remote: scheme is fixed and ssh-remote part can be extracted from vscode.env.remoteName variable, the last piece I need is the hostname that was used to open current VSCode Remote session. Is there any API/variable to discover this?

0 Answers
Related