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

Support multiselection in 'Add Folder to Workspace...' dialog #9684

Merged
merged 1 commit into from
Jul 14, 2021

Conversation

colin-grant-work
Copy link
Contributor

Signed-off-by: Colin Grant colin.grant@ericsson.com

What it does

Fixes #9665 by allowing multiple selection in the workspace dialog and ensuring that the public methods 'addRoot' and 'removeRoots' (and new method addRoots) don't return before the ._roots field of the WorkspaceService has been updated. Previously, changes to the workspace would emit an event that would trigger an updateWorkspace cycle, but since that method is also asynchronous, it was guaranteed not to have finished its work in the tick after addRoot and removeRoots resolved, meaning that even awaiting those methods didn't guarantee that the WorkspaceService was ready for another call.

How to test

  1. Open a workspace.
  2. Use the 'Add folder to workspace' command (available in the ... context menu in the explorer).
  3. Select several folders.
  4. Observe that your workspace updates correctly to include all of the folders added.

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto added dialogs issues related to dialogs multi-root issues related to multi-root support workspace issues related to the workspace labels Jul 1, 2021
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I can confirm that the changes allow to select multiple folders in the browser and Electron (Ubuntu) environment.

@colin-grant-work colin-grant-work force-pushed the feature/add-folder-multiselect branch from 48efa1b to 80f6db0 Compare July 2, 2021 14:09
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that the behavior works as intended:

  • verified without a *.theia-workspace file present and adding multiple roots
  • verified with a previous *.theia-workspace file present and adding multiple roots
  • adding a single workspace root works as before

Signed-off-by: Colin Grant <colin.grant@ericsson.com>
@colin-grant-work colin-grant-work force-pushed the feature/add-folder-multiselect branch from 80f6db0 to abc51a9 Compare July 13, 2021 16:27
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes work for me 👍

Comment on lines +372 to 375
async addRoot(uris: URI[] | URI): Promise<void> {
const toAdd = Array.isArray(uris) ? uris : [uris];
await this.spliceRoots(this._roots.length, 0, ...toAdd);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it can be simplified to:

async addRoot(...uris: URI[]): Promise<void> {
    await this.spliceRoots(this._roots.length, 0, ...uris);
}

Calls like the following are allowed:

await this.workspaceService.addRoot(...workspaceFolders);
await this.workspaceService.addRoot(uri);

But I won't nitpick :)

@colin-grant-work colin-grant-work merged commit a38224c into master Jul 14, 2021
@colin-grant-work colin-grant-work deleted the feature/add-folder-multiselect branch July 14, 2021 16:40
@github-actions github-actions bot added this to the 1.16.0 milestone Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialogs issues related to dialogs multi-root issues related to multi-root support workspace issues related to the workspace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add folder to workspace... dialog should support multiselection
3 participants