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

[remote] Allow to open remote files through vscode://vscode-remote/ #108257

Closed
phknot opened this issue Oct 7, 2020 · 17 comments
Closed

[remote] Allow to open remote files through vscode://vscode-remote/ #108257

phknot opened this issue Oct 7, 2020 · 17 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities remote Remote system operations issues verified Verification succeeded
Milestone

Comments

@phknot
Copy link

phknot commented Oct 7, 2020

When clicking on link in the form of vscode://vscode-remote/wsl+distro/path/to/file/in/open/workspace my current VS Code window is closed, and the file is opened in another window.

Expected behaviour would be that the file opens in your already open VS Code instance that's connected to that remote. This is also how VS Code behaves when opening the same file via the command line: code --remote wsl+remote /path/to/file/in/open/workspace.

Opening the links in your existing session would be great for opening stacktrace links from the browser and going directly to the code.

@aeschli
Copy link
Contributor

aeschli commented Oct 13, 2020

Currently, URL starting with vscode://vscode-remote/ can only open folders not files.

@dpatou Just pinged me with the same request

@aeschli
Copy link
Contributor

aeschli commented Oct 13, 2020

For remote URIs we can't do a stat to find out if the URI is a file or a folder.

  • When opening a vscode: uri we always treat it as folder unless it ends with .code-workspace, then it's a workspace
  • On the command line, we have a heuristic:
    • it's a folder if it ends with a slash
    • it's a workspace if it ends with .code-workspace,
    • it's a file if the name contains a dot

@bpasero I think you originally added the vscode handler for remote URI. Should we use the same heuristic as for the command line (which also has it's weaknesses)? You might know if that can break existing usages.
Alternative is to add a query parameter ?fileURI=true. If we add such a parameter we should also support it on the command line.

@bpasero
Copy link
Member

bpasero commented Oct 13, 2020

@aeschli this code is used to support "Open in Desktop" from codespaces, so I am not sure we can do a change that risks breaking this flow. After all, repository names can possibly include ".".

@bpasero bpasero added the remote Remote system operations issues label Oct 13, 2020
@dpatou
Copy link

dpatou commented Oct 13, 2020

Alternative is to add a query parameter ?fileURI=true. If we add such a parameter we should also support it on the command line.

This seems to be the most reliable, and kinda "fixes" the current caveats of the command line in file/workspace/folder detection.

@bpasero does the open in desktop feature of codespace supports opening a given file/line-in-file (I haven't been able to access codespace yet) ?

@bpasero
Copy link
Member

bpasero commented Oct 13, 2020

No, the idea is only to open workspaces/folders.

@aeschli aeschli added the feature-request Request for new features or functionality label Nov 5, 2020
@aeschli aeschli changed the title vscode://vscode-remote/wsl+distro links always opening in a new window Allow to open remote files through vscode://vscode-remote/ Nov 5, 2020
@aeschli aeschli added this to the Backlog Candidates milestone Nov 5, 2020
@aeschli aeschli changed the title Allow to open remote files through vscode://vscode-remote/ [remote] Allow to open remote files through vscode://vscode-remote/ Nov 6, 2020
@aeschli aeschli modified the milestones: Backlog Candidates, Backlog Jan 21, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2021
@aeschli aeschli reopened this Apr 21, 2021
@aeschli aeschli added the help wanted Issues identified as good community contribution opportunities label Apr 21, 2021
@aeschli
Copy link
Contributor

aeschli commented Apr 21, 2021

I suggest we allow the :line:column syntax for the vscode protocol and use it to detect that the URI is a file uri.

In fact it's already works for local files, e.g. vscode-oss://file/home/martin/foo.txt:10 will open foo.txt at line 10

@aeschli aeschli modified the milestones: Backlog, April 2021 Apr 21, 2021
@aeschli
Copy link
Contributor

aeschli commented Apr 21, 2021

With the pushed change, it is now possible to open remote files.

To indicate that a remote URL is a file, not a folder, the path needs to be followed by :linenumber[:column].

@aeschli aeschli added the verification-needed Verification of issue is requested label Apr 26, 2021
@aeschli
Copy link
Contributor

aeschli commented Apr 26, 2021

To verify on WSL (or on any other remote)

  • run the Devloper: Open URL command
  • vscode://vscode-remote/wsl+distro/path/to/file:1:1 should open file

@dbaeumer
Copy link
Member

Doesn't work for me. I am use the following URL

vscode://vscode-remote/wsl+Ubuntu-20.04/home/dirkb/tmp/package.json:1:1

And the file clearly exist on my file system

cast

@dbaeumer dbaeumer reopened this Apr 28, 2021
@dbaeumer dbaeumer added the verification-found Issue verification failed label Apr 28, 2021
@alexdima alexdima modified the milestones: April 2021, May 2021 Apr 30, 2021
@aeschli
Copy link
Contributor

aeschli commented May 4, 2021

Ok, my bad, but when using insiders, it's vscode-insiders://vscode-remote/wsl+distro/path/to/file:1:1

@aeschli aeschli closed this as completed May 4, 2021
@aeschli aeschli removed the verification-found Issue verification failed label May 4, 2021
@aeschli aeschli modified the milestones: May 2021, April 2021 May 4, 2021
@chrisdias
Copy link
Member

I tested the following and all seemed to work properly, opening the file (only) at the appropriate line/column. The last option opened the folder as expected.

  • vscode-insiders://vscode-remote/wsl+Ubuntu/home/chrisdias/src/myexpressapp/app.js:1:1
  • vscode-insiders://vscode-remote/wsl+Ubuntu/home/chrisdias/src/myexpressapp/app.js:1:20
  • vscode-insiders://vscode-remote/wsl+Ubuntu/home/chrisdias/src/myexpressapp/app.js:20:1
  • vscode-insiders://vscode-remote/wsl+Ubuntu/home/chrisdias/src/myexpressapp

If I provided the wrong path, a new unsaved file named app.js was opened.

  • vscode-insiders://vscode-remote/wsl+Ubuntu/home/BLAH/src/myexpressapp/app.js:20:1

What I can't see, and don't know if its supported, is how to open the folder and the file at the same time, such that the myexpressapp workspace is opened, with app.js opened on a particular line/column.

@TylerLeonhardt
Copy link
Member

Moving out to May and reopening so @chrisdias's comment doesn't get lost but @aeschli please do what you want with this issue.

@TylerLeonhardt TylerLeonhardt reopened this May 5, 2021
@TylerLeonhardt TylerLeonhardt modified the milestones: April 2021, May 2021 May 5, 2021
@chrisdias
Copy link
Member

to be clear - the files opened in the existing instance of Insiders. opening the folder resulted in a reload of the current instance.

@aeschli
Copy link
Contributor

aeschli commented May 10, 2021

Through the vscode/'vscode-insiders' protocol handler, we only support opening one resource a time. I believe that's how a protocol handler typically works.
This feature request was just also allow opening a remote file, not only a remote folder.

@chrisdias Can you file a new feature request with your your use case?

@aeschli aeschli modified the milestones: May 2021, April 2021 May 10, 2021
@bpasero bpasero modified the milestones: April 2021, May 2021 May 28, 2021
@aeschli aeschli closed this as completed May 31, 2021
@aeschli aeschli modified the milestones: May 2021, April 2021 Jun 2, 2021
@aeschli aeschli added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities remote Remote system operations issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

9 participants