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 showOpenDialog to open local files #131138

Open
connor4312 opened this issue Aug 19, 2021 · 15 comments
Open

Allow showOpenDialog to open local files #131138

connor4312 opened this issue Aug 19, 2021 · 15 comments
Assignees
Labels
api api-proposal feature-request Request for new features or functionality simple-file-dialog Issues with simple file dialog
Milestone

Comments

@connor4312
Copy link
Member

In the demo in https://github.com/microsoft/vscode-internalbacklog/issues/2178#issuecomment-901514989, I had to manually create a file in the web workspace since I couldn't figure out a way to get vscode.window.showOpenDialog to open a file on the user's machine. Rob suggested that adding a file:/// URI as the defaultUri might work, but it doesn't.

Is opening a local file in this way already possible, and if not could we add a way for it to happen, perhaps using the defaultUri as Rob suggested?

@connor4312 connor4312 added the feature-request Request for new features or functionality label Aug 19, 2021
@bpasero bpasero assigned alexr00 and unassigned bpasero Aug 19, 2021
@bpasero bpasero added simple-file-dialog Issues with simple file dialog web Issues related to running VSCode in the web and removed feature-request Request for new features or functionality labels Aug 19, 2021
@microsoft microsoft deleted a comment from bpasero Aug 19, 2021
@alexr00
Copy link
Member

alexr00 commented Aug 19, 2021

There was some discussion somewhere about whether we should allow extensions to open local files on web which I now cannot find. If I remember correctly, the outcome of the discussion was that we wouldn't allow it for now because:

  • we didn't have compelling reason to allow it.
  • it was probably almost never what the extension wanted to do and more likely would result from a programming error.

Now we have a real need for it now though. Given the potential for error here, we should consider making the local file option for vscode.window.showOpenDialog opt-in, and not something that could be done by accident. Similar to the availableFilesystems option we have internally:

export interface IPickAndOpenOptions {
forceNewWindow?: boolean;
defaultUri?: URI;
telemetryExtraData?: ITelemetryData;
availableFileSystems?: string[];
remoteAuthority?: string | null;
}

@alexr00 alexr00 added the api label Aug 19, 2021
@alexr00 alexr00 added this to the On Deck milestone Aug 19, 2021
@alexr00 alexr00 added the feature-request Request for new features or functionality label Aug 19, 2021
@connor4312
Copy link
Member Author

Sounds good. Let's dive into this more next iteration; Kai would like to get the referenced experience going by the end of this year :)

@connor4312 connor4312 self-assigned this Aug 19, 2021
@connor4312 connor4312 modified the milestones: On Deck, September 2021 Aug 19, 2021
@connor4312
Copy link
Member Author

Actually with the new approach with embedder-side code in vscode.dev I don't really need this -- I can have a custom command added in the embedder which opens a file and passes it back down. Having an API for this would make it simpler, though, and there may be other use cases, so I'll leave it open.

@connor4312 connor4312 modified the milestones: September 2021, On Deck Sep 15, 2021
@connor4312
Copy link
Member Author

I think this will still be eventually needed, but my particular use case is no longer required.

@connor4312 connor4312 removed their assignment Oct 13, 2021
@alexr00 alexr00 modified the milestones: On Deck, Backlog Oct 15, 2021
@bpasero
Copy link
Member

bpasero commented Dec 22, 2021

This seems to work fine for me now?
recording

@alexr00
Copy link
Member

alexr00 commented Dec 22, 2021

@bpasero extension API still can't cause the "Show Local" button to show.

@bpasero
Copy link
Member

bpasero commented Dec 22, 2021

Ah ok 👍

alexr00 added a commit that referenced this issue Feb 6, 2023
@alexr00
Copy link
Member

alexr00 commented Feb 6, 2023

Proposal:

export interface OpenDialogOptions {
/**
* Controls whether the dialog allows users to select local files via the "Show Local" button.
* Extensions that set this to `true` should check the scheme of the selected file.
*
* TODO: Workspace extensions already get only `file` scheme URIs back from the dialog. How will we tell the extension that the file is local?
*/
allowLocal?: boolean;
}

@jrieken
Copy link
Member

jrieken commented Feb 7, 2023

alt name; allowUIResources

@alexr00 alexr00 changed the title Allow showOpenDialog to open local files on web Allow showOpenDialog to open local files Feb 8, 2023
@alexr00 alexr00 removed the web Issues related to running VSCode in the web label Feb 8, 2023
alexr00 added a commit that referenced this issue Feb 8, 2023
alexr00 added a commit that referenced this issue Feb 8, 2023
alexr00 added a commit that referenced this issue Feb 9, 2023
* Propose "allowLocal" open dialog option API
Part of #131138

* Update comment

* allowUIResources API proposal
Part of #131138

* Fix scheme ordering and update doc comment
@alexr00 alexr00 modified the milestones: February 2023, Backlog Feb 15, 2023
c-claeys pushed a commit to c-claeys/vscode that referenced this issue Feb 16, 2023
* Propose "allowLocal" open dialog option API
Part of microsoft#131138

* Update comment

* allowUIResources API proposal
Part of microsoft#131138

* Fix scheme ordering and update doc comment
@gulshan
Copy link

gulshan commented Feb 23, 2023

Can the "web/remote" open file view be made available for opening local files also, through a setting?

@alexr00
Copy link
Member

alexr00 commented Feb 23, 2023

It already is! "files.simpleDialog.enable": true

@gulshan
Copy link

gulshan commented Feb 23, 2023

Did not know that! Thanks.

@alexr00 alexr00 added the *out-of-scope Posted issue is not in scope of VS Code label Dec 10, 2024
@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@alexr00 alexr00 removed the *out-of-scope Posted issue is not in scope of VS Code label Dec 10, 2024
@microsoft microsoft deleted a comment from vs-code-engineering bot Dec 10, 2024
@alexr00 alexr00 closed this as completed Dec 10, 2024
@alexr00 alexr00 reopened this Dec 10, 2024
@connor4312
Copy link
Member Author

The prototype this was for is not the direction we ended up going, so I don't need this any more, but it might be otherwise useful

@alexr00
Copy link
Member

alexr00 commented Dec 11, 2024

@connor4312 , If you're not using it, I'll delete the vscode.proposed file for it.

Do you have another use for this? I haven't heard from any extension authors that need this. I'm inclined to clone as out of scope since I don't foresee us adding this any time soon.

@connor4312
Copy link
Member Author

Not so far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api api-proposal feature-request Request for new features or functionality simple-file-dialog Issues with simple file dialog
Projects
None yet
Development

No branches or pull requests

5 participants