-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Comments
I don't know how to +1 this but I hope this gets noticed by the devs |
@laaaaanceeee On my first comment above there's a little 👍 icon you can click to add your "vote". |
@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 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? |
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.
pls note the following comment in the API documentation
Adding @bpasero |
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
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! |
@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 Is there a specific scenario that the current API does not allow you to do? |
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 :-)) |
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).
The text was updated successfully, but these errors were encountered: