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

Supply multiselects to scm/resourceGroup/context menu commands (fix #92337) #192172

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f374f04
Supply multiselects to `scm/resourceGroup/context` menu commands (fix…
gjsjohnmurray Sep 5, 2023
851f1af
Merge branch 'main' into fix-92337
gjsjohnmurray Sep 13, 2023
2ed97bd
Merge branch 'main' into fix-92337
gjsjohnmurray Sep 17, 2023
cd140cf
Merge branch 'main' into fix-92337
gjsjohnmurray Oct 11, 2023
33fc950
Merge remote-tracking branch 'upstream/main' into fix-92337
gjsjohnmurray Nov 23, 2023
f51aaa0
Merge remote-tracking branch 'upstream/main' into fix-92337
gjsjohnmurray Jan 18, 2024
bc3dbd4
Merge branch 'main' into fix-92337
gjsjohnmurray Feb 29, 2024
456cd57
Merge branch 'main' into fix-92337
gjsjohnmurray Mar 15, 2024
a4d24ef
Merge branch 'main' into fix-92337
gjsjohnmurray Mar 21, 2024
fde6a37
Merge branch 'main' into fix-92337
gjsjohnmurray Apr 5, 2024
6377d0d
Merge branch 'main' into fix-92337
gjsjohnmurray Apr 11, 2024
42ce034
Merge branch 'main' into fix-92337
gjsjohnmurray Apr 20, 2024
8c6b244
Merge branch 'main' into fix-92337
gjsjohnmurray May 2, 2024
3ad8414
Merge branch 'main' into fix-92337
gjsjohnmurray May 3, 2024
b62bf21
Merge branch 'main' into fix-92337
gjsjohnmurray May 7, 2024
e7594e0
Merge branch 'main' into fix-92337
gjsjohnmurray May 21, 2024
c735150
Merge branch 'main' into fix-92337
gjsjohnmurray Jun 11, 2024
caa801e
Merge branch 'main' into fix-92337
gjsjohnmurray Jun 19, 2024
f695b4c
Merge branch 'main' into fix-92337
gjsjohnmurray Jul 4, 2024
0ba4e8e
Merge branch 'main' into fix-92337
gjsjohnmurray Jul 10, 2024
507b1b4
Merge branch 'main' into fix-92337
gjsjohnmurray Jul 27, 2024
7fc427c
Merge branch 'main' into fix-92337
gjsjohnmurray Jul 31, 2024
8e4f3e7
Merge remote-tracking branch 'upstream/main' into fix-92337
gjsjohnmurray Sep 2, 2024
0fefabe
Merge branch 'main' into fix-92337
gjsjohnmurray Sep 2, 2024
7b424bf
Fix faulty merge
gjsjohnmurray Sep 2, 2024
9d39c51
Merge branch 'main' into fix-92337
gjsjohnmurray Sep 2, 2024
ffad1b1
Merge branch 'main' into fix-92337
gjsjohnmurray Oct 4, 2024
cf39e52
Merge branch 'main' into fix-92337
gjsjohnmurray Jan 7, 2025
ac8e2bc
Merge branch 'main' into fix-92337
gjsjohnmurray Jan 8, 2025
6886752
Merge branch 'main' into fix-92337
gjsjohnmurray Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/vs/workbench/contrib/scm/browser/scmViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class ResourceGroupRenderer implements ICompressibleTreeRenderer<ISCMResourceGro

constructor(
private actionViewItemProvider: IActionViewItemProvider,
private actionRunner: ActionRunner,
@ISCMViewService private scmViewService: ISCMViewService
) { }

Expand All @@ -474,7 +475,10 @@ class ResourceGroupRenderer implements ICompressibleTreeRenderer<ISCMResourceGro
const element = append(container, $('.resource-group'));
const name = append(element, $('.name'));
const actionsContainer = append(element, $('.actions'));
const actionBar = new ActionBar(actionsContainer, { actionViewItemProvider: this.actionViewItemProvider });
const actionBar = new ActionBar(actionsContainer, {
actionViewItemProvider: this.actionViewItemProvider,
actionRunner: this.actionRunner
});
const countContainer = append(element, $('.count'));
const count = new CountBadge(countContainer, {}, defaultCountBadgeStyles);
const disposables = combinedDisposable(actionBar);
Expand Down Expand Up @@ -528,7 +532,7 @@ interface RenderedResourceData {

class RepositoryPaneActionRunner extends ActionRunner {

constructor(private getSelectedResources: () => (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[]) {
constructor(private getSelectedResources: (wantResourceGroups: boolean) => (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[]) {
super();
}

Expand All @@ -537,7 +541,7 @@ class RepositoryPaneActionRunner extends ActionRunner {
return super.runAction(action, context);
}

const selection = this.getSelectedResources();
const selection = this.getSelectedResources(!(context as ISCMResource).resourceGroup);
const contextIsSelected = selection.some(s => s === context);
const actualContext = contextIsSelected ? selection : [context];
const args = actualContext.map(e => ResourceTree.isResourceNode(e) ? ResourceTree.collect(e) : [e]).flat();
Expand Down Expand Up @@ -3251,7 +3255,7 @@ export class SCMViewPane extends ViewPane {
this.listLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility });
this.disposables.add(this.listLabels);

const resourceActionRunner = new RepositoryPaneActionRunner(() => this.getSelectedResources());
const resourceActionRunner = new RepositoryPaneActionRunner((wantResourceGroups) => this.getSelectedResources(wantResourceGroups));
resourceActionRunner.onWillRun(() => this.tree.domFocus(), this, this.disposables);
this.disposables.add(resourceActionRunner);

Expand Down Expand Up @@ -3284,7 +3288,7 @@ export class SCMViewPane extends ViewPane {
this.inputRenderer,
this.actionButtonRenderer,
this.instantiationService.createInstance(RepositoryRenderer, MenuId.SCMTitle, getActionViewItemProvider(this.instantiationService)),
this.instantiationService.createInstance(ResourceGroupRenderer, getActionViewItemProvider(this.instantiationService)),
this.instantiationService.createInstance(ResourceGroupRenderer, getActionViewItemProvider(this.instantiationService), resourceActionRunner),
this.instantiationService.createInstance(ResourceRenderer, () => this.viewMode, this.listLabels, getActionViewItemProvider(this.instantiationService), resourceActionRunner),
this.instantiationService.createInstance(HistoryItemGroupRenderer, historyItemGroupActionRunner),
this.instantiationService.createInstance(HistoryItemRenderer, historyItemActionRunner, getActionViewItemProvider(this.instantiationService)),
Expand Down Expand Up @@ -3567,7 +3571,7 @@ export class SCMViewPane extends ViewPane {
const element = e.element;
let context: any = element;
let actions: IAction[] = [];
let actionRunner: IActionRunner = new RepositoryPaneActionRunner(() => this.getSelectedResources());
let actionRunner: IActionRunner = new RepositoryPaneActionRunner((wantResourceGroups) => this.getSelectedResources(wantResourceGroups));

if (isSCMRepository(element)) {
const menus = this.scmViewService.menus.getRepositoryMenus(element.provider);
Expand Down Expand Up @@ -3636,9 +3640,9 @@ export class SCMViewPane extends ViewPane {
return Array.from(new Set<ISCMRepository>([...focusedRepositories, ...selectedRepositories]));
}

private getSelectedResources(): (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[] {
private getSelectedResources(wantResourceGroups: boolean): (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[] {
return this.tree.getSelection()
.filter(r => !!r && !isSCMResourceGroup(r))! as any;
.filter(r => !!r && wantResourceGroups ? isSCMResourceGroup(r) : !isSCMResourceGroup(r))! as any;
}

private getSelectedHistoryItems(): SCMHistoryItemViewModelTreeElement[] {
Expand Down