Skip to content

Commit 4d351f3

Browse files
committed
Avoids showing filter header when not applicable
1 parent 5718b6c commit 4d351f3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/views/viewBase.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,10 @@ export abstract class ViewBase<
596596
private addHeaderNode(node: ViewNode, promise: ViewNode[] | Promise<ViewNode[]>): ViewNode[] | Promise<ViewNode[]> {
597597
if (node !== this.root) return promise;
598598

599+
const { openRepositories: repos } = this.container.git;
600+
599601
// If we are not grouped and we are either not filterable or there aren't multiple repos open, then just return the promise
600-
if (
601-
!this.grouped &&
602-
(!this.isAny(...treeViewTypesSupportsRepositoryFilter) || this.container.git.openRepositories.length <= 1)
603-
) {
602+
if (!this.grouped && (!this.isAny(...treeViewTypesSupportsRepositoryFilter) || repos.length <= 1)) {
604603
return promise;
605604
}
606605

@@ -627,6 +626,16 @@ export abstract class ViewBase<
627626
return children;
628627
};
629628

629+
if (!this.grouped && this.supportsWorktreeCollapsing) {
630+
return groupRepositories(repos).then(grouped => {
631+
if (grouped.size <= 1) return promise;
632+
633+
return isPromise(promise)
634+
? promise.then(c => ensureGroupedHeaderNode(c))
635+
: ensureGroupedHeaderNode(promise);
636+
});
637+
}
638+
630639
return isPromise(promise) ? promise.then(c => ensureGroupedHeaderNode(c)) : ensureGroupedHeaderNode(promise);
631640
}
632641

0 commit comments

Comments
 (0)