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

Provide all selected URIs for command execution #11424

Closed
wants to merge 1 commit into from

Conversation

msujew
Copy link
Member

@msujew msujew commented Jul 14, 2022

What it does

Closes #10198

VSCode provides in addition to the URI of the last selected file in the explorer also an array of all selected URIs. This change aligns Theia to this behavior.

How to test

  1. Install the test extension (source)
  2. Select multiple/one file in the file explorer
  3. Use the Show URIs command in the context menu of the file explorer
  4. It should show the same output as if installed in vscode, including all selected URIs

Review checklist

Reminder for reviewers

@msujew msujew added the vscode issues related to VSCode compatibility label Jul 14, 2022
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 confirm that the changes work as expected with the provided test extension 👍

@colin-grant-work
Copy link
Contributor

@msujew, I merged #11290 ahead of this and created a conflict, sorry! Now this should be done in the plugin menu command adapter, rather than the menu contribution handler.

@msujew msujew force-pushed the msujew/provide-selected-uris branch 2 times, most recently from b6967cc to 82050e7 Compare July 15, 2022 15:57
@msujew
Copy link
Member Author

msujew commented Jul 15, 2022

@colin-grant-work Thanks for the hint, I was able to rebase easily 👍

@@ -245,13 +245,19 @@ export class PluginMenuCommandAdapter implements MenuCommandAdapter {
return treeArgs;
}

protected getSelectedResource(): [CodeUri | TreeViewSelection | undefined] {
protected getSelectedResource(): (CodeUri | CodeUri[] | TreeViewSelection | undefined)[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest this more exact typing?

    protected getSelectedResources(): [CodeUri | TreeViewSelection | undefined, CodeUri[] | undefined] {
        const selection = this.selectionService.selection;
        const firstMember = TreeWidgetSelection.is(selection) && selection.source instanceof TreeViewWidget && selection[0]
            ? selection.source.toTreeViewSelection(selection[0])
            : (UriSelection.getUri(selection) ?? this.resourceContextKey.get())?.['codeUri'];
        const secondMember = TreeWidgetSelection.is(selection)
            ? UriSelection.getUris(selection).map(uri => uri['codeUri'])
            : undefined;
        return [firstMember, secondMember];
    }

@msujew msujew closed this Jul 15, 2022
@msujew msujew force-pushed the msujew/provide-selected-uris branch from 82050e7 to 1764529 Compare July 15, 2022 20:48
@msujew msujew deleted the msujew/provide-selected-uris branch July 15, 2022 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants