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

Add a command to add a folder to a workspace #43674

Closed
DanTup opened this issue Feb 14, 2018 · 8 comments
Closed

Add a command to add a folder to a workspace #43674

DanTup opened this issue Feb 14, 2018 · 8 comments
Assignees

Comments

@DanTup
Copy link
Contributor

DanTup commented Feb 14, 2018

There's a vscode.openFolder command but doesn't seem to be one that will add a folder to the workspace.

This would be really useful for a "new project" command I'm working on (if you invoke it from within a workspace I want to add it, not replace the workspace with just the new folder).

@curious-monggo
Copy link

I don't know how to +1 this but I hope this gets noticed by the devs

@DanTup
Copy link
Contributor Author

DanTup commented Feb 15, 2018

@laaaaanceeee On my first comment above there's a little 👍 icon you can click to add your "vote".

@egamma
Copy link
Member

egamma commented Feb 16, 2018

@DanTup there is proposed API pls check whether this covers your needs https://code.visualstudio.com/updates/v1_20#_add-remove-and-change-workspace-folders.

Here is more info about proposed APIs https://code.visualstudio.com/updates/v1_20#_proposed-extension-apis.

I´m closing this issue, please reopen a separate issue when the proposed API doesn´t cover your needs.

@egamma egamma closed this as completed Feb 16, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Feb 16, 2018

@egamma I think that'll work fine, thanks! Though the API for delete seems a bit wonky - why delete by index/count and not Uri? Not only is it a bit weird it's more likely to suffer from race conditions if not synchronous whereas the URIs can't be interpreted wrongly?

@egamma egamma assigned bpasero and unassigned jrieken Feb 16, 2018
@egamma
Copy link
Member

egamma commented Feb 16, 2018

The goal was to have a minimal API that supports adding/removing multiple folders in one call. For this reason we went an Array.splice style API.

it's more likely to suffer from race conditions if not synchronous

pls note the following comment in the API documentation

* **Note:** it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times
* without waiting for the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) to fire.

Adding @bpasero

@DanTup
Copy link
Contributor Author

DanTup commented Feb 16, 2018

The goal was to have a minimal API that supports adding/removing multiple folders in one call

I'm not sure I understand why an array of the Uris/WorkspaceFolders to remove wouldn't do this? (I'm not actually like to use this so it doesn't affect me, I'm just thinking that once you put this in it's gonna be hard to change):

updateWorkspaceFolders(
  start: number,
  workspaceFoldersToAdd?: { uri: Uri, name?: string }[],
  workspaceFoldersToRemove?: Uri[] | WorkspaceFolder[]
): boolean

pls note the following comment in the API documentation

I was thinking more about if the extension had gotten a list of workspaceFolders and did something async (eg. check if they contain a specific file or something) and then called this but the user had added/removed a folder in the meantime, the indexes could all be wrong. Indexes/lengths can't be wrong if you don't have them :-)

Again, I don't feel strongly about this, it just feels a bit so I thought I'd mention!

@bpasero
Copy link
Member

bpasero commented Feb 16, 2018

@DanTup I do not understand that argument about long running tasks and race conditions. You should always before you call into this method check the contents of the vscode.workspace.workspaceFolders array to ensure you are doing the right thing.

Is there a specific scenario that the current API does not allow you to do?

@DanTup
Copy link
Contributor Author

DanTup commented Feb 16, 2018

Nothing I can't do; just felt wonky. The user is likely to already have a WorkspaceFolder or Uri for what they'd like to remove, it seems weird to have them convert it to indexes when Code could do it with a nicer interface.

Personally I only need the add functionality so it's not something I feel strongly about; I just wanted to provide the feedback (and I totally appreciate you're way better placed to make decisions like this than me :-))

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants