diff --git a/src/view/prChangesTreeDataProvider.ts b/src/view/prChangesTreeDataProvider.ts index 53f6d0a38d..2ce2757191 100644 --- a/src/view/prChangesTreeDataProvider.ts +++ b/src/view/prChangesTreeDataProvider.ts @@ -38,6 +38,7 @@ export class PullRequestChangesTreeDataProvider extends Disposable implements vs this._view = this._register(vscode.window.createTreeView('prStatus:github', { treeDataProvider: this, showCollapseAll: true, + canSelectMany: true })); this._register( @@ -54,7 +55,7 @@ export class PullRequestChangesTreeDataProvider extends Disposable implements vs }), ); - this._register(this._view.onDidChangeCheckboxState(TreeUtils.processCheckboxUpdates)); + this._register(this._view.onDidChangeCheckboxState(e => TreeUtils.processCheckboxUpdates(e, this._view.selection))); } refresh(treeNode?: TreeNode) { diff --git a/src/view/prsTreeDataProvider.ts b/src/view/prsTreeDataProvider.ts index c01a83dc87..024f78cee2 100644 --- a/src/view/prsTreeDataProvider.ts +++ b/src/view/prsTreeDataProvider.ts @@ -95,7 +95,7 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T } })); - this._register(this._view.onDidChangeCheckboxState(TreeUtils.processCheckboxUpdates)); + this._register(this._view.onDidChangeCheckboxState(e => TreeUtils.processCheckboxUpdates(e, []))); this._register(this._view.onDidExpandElement(expanded => { this.prsTreeModel.updateExpandedQueries(expanded.element, true); diff --git a/src/view/treeNodes/treeUtils.ts b/src/view/treeNodes/treeUtils.ts index aac0523229..3bde5a5863 100644 --- a/src/view/treeNodes/treeUtils.ts +++ b/src/view/treeNodes/treeUtils.ts @@ -8,7 +8,9 @@ import { FileChangeNode } from './fileChangeNode'; import { TreeNode } from './treeNode'; export namespace TreeUtils { - export function processCheckboxUpdates(checkboxUpdates: vscode.TreeCheckboxChangeEvent) { + export function processCheckboxUpdates(checkboxUpdates: vscode.TreeCheckboxChangeEvent, selection: readonly TreeNode[]) { + const selectionContainsUpdates = selection.some(node => checkboxUpdates.items.some(update => update[0] === node)); + const checkedNodes: FileChangeNode[] = []; const uncheckedNodes: FileChangeNode[] = []; @@ -27,6 +29,21 @@ export namespace TreeUtils { node.updateFromCheckboxChanged(newState); }); + if (selectionContainsUpdates) { + for (const selected of selection) { + if (!(selected instanceof FileChangeNode)) { + continue; + } + if (!checkedNodes.includes(selected) && !uncheckedNodes.includes(selected)) { + if (selected.checkboxState.state === vscode.TreeItemCheckboxState.Unchecked) { + checkedNodes.push(selected); + } else { + uncheckedNodes.push(selected); + } + } + } + } + if (checkedNodes.length > 0) { const prModel = checkedNodes[0].pullRequest; const filenames = checkedNodes.map(n => n.fileName);