Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/view/prChangesTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/view/prsTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 18 additions & 1 deletion src/view/treeNodes/treeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { FileChangeNode } from './fileChangeNode';
import { TreeNode } from './treeNode';

export namespace TreeUtils {
export function processCheckboxUpdates(checkboxUpdates: vscode.TreeCheckboxChangeEvent<TreeNode>) {
export function processCheckboxUpdates(checkboxUpdates: vscode.TreeCheckboxChangeEvent<TreeNode>, selection: readonly TreeNode[]) {
const selectionContainsUpdates = selection.some(node => checkboxUpdates.items.some(update => update[0] === node));

const checkedNodes: FileChangeNode[] = [];
const uncheckedNodes: FileChangeNode[] = [];

Expand All @@ -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);
Expand Down