From 0386760e20c477cea3f34975857371bf161bf11e Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Mon, 23 Jan 2023 15:33:21 +0100 Subject: [PATCH] git: show repositories and global actions for multi-repo projects without common branches in branches tree popup GitOrigin-RevId: 2ce93df6b8090d13d8f7eaa3665427ca8ccf50d6 --- .../src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt | 3 ++- .../git4idea/ui/branch/tree/GitBranchesTreeMultiRepoModel.kt | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt b/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt index b6426e19ebf5..5e610c3a8d60 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt +++ b/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt @@ -187,7 +187,8 @@ class GitBranchesTreePopup(project: Project, step: GitBranchesTreePopupStep, par traverseNodesAndExpand() expandPreviouslyExpandedBranches() } - super.updateSpeedSearchColors(!haveBranches) + val model = tree.model + super.updateSpeedSearchColors(model.getChildCount(model.root) == 0) if (!pattern.isNullOrBlank()) { tree.emptyText.text = GitBundle.message("git.branches.popup.tree.no.branches", pattern) } diff --git a/plugins/git4idea/src/git4idea/ui/branch/tree/GitBranchesTreeMultiRepoModel.kt b/plugins/git4idea/src/git4idea/ui/branch/tree/GitBranchesTreeMultiRepoModel.kt index c7d84aa33608..b5986cd2b763 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/tree/GitBranchesTreeMultiRepoModel.kt +++ b/plugins/git4idea/src/git4idea/ui/branch/tree/GitBranchesTreeMultiRepoModel.kt @@ -61,7 +61,7 @@ class GitBranchesTreeMultiRepoModel( || (node === GitBranchType.REMOTE && commonRemoteBranchesTree.isEmpty()) private fun getChildren(parent: Any?): List { - if (parent == null || !haveFilteredBranches()) return emptyList() + if (parent == null) return emptyList() return when (parent) { TreeRoot -> getTopLevelNodes() is GitBranchType -> branchesTreeCache.getOrPut(parent) { getBranchTreeNodes(parent, emptyList()) } @@ -91,6 +91,4 @@ class GitBranchesTreeMultiRepoModel( private fun getPreferredBranch(): GitBranch? = getPreferredBranch(project, repositories, null, commonLocalBranchesTree, commonRemoteBranchesTree) - - private fun haveFilteredBranches(): Boolean = !commonLocalBranchesTree.isEmpty() || !commonRemoteBranchesTree.isEmpty() }