Collapse selection after deleting a range of remote branches

We only want to do this when the function is called from the remote branches
panel. It can also be called with a selection of local branches in order to
delete their remote branches, but in this case the selection shouldn't be
collapsed because the local branches stay around.
This commit is contained in:
Stefan Haller committed 2025-07-04 17:20:22 +02:00
1 parent 80a614d330
commit 4b33efffbe
3 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -535,7 +535,7 @@ func (self *BranchesController) remoteDelete(branches []*models.Branch) error {
remoteBranches := lo.Map(branches, func(branch *models.Branch, _ int) *models.RemoteBranch {
return &models.RemoteBranch{Name: branch.UpstreamBranch, RemoteName: branch.UpstreamRemote}
})
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(remoteBranches)
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(remoteBranches, false)
}
func (self *BranchesController) localAndRemoteDelete(branches []*models.Branch) error {
@@ -82,7 +82,7 @@ func (self *BranchesHelper) ConfirmLocalDelete(branches []*models.Branch) error
return nil
}
func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteBranch) error {
func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteBranch, resetRemoteBranchesSelection bool) error {
var title string
if len(remoteBranches) == 1 {
title = utils.ResolvePlaceholderString(
@@ -115,6 +115,9 @@ func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteB
return err
}
self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
if resetRemoteBranchesSelection {
self.c.Contexts().RemoteBranches.CollapseRangeSelectionToTop()
}
return nil
})
},
@@ -133,7 +133,7 @@ func (self *RemoteBranchesController) context() *context.RemoteBranchesContext {
}
func (self *RemoteBranchesController) delete(selectedBranches []*models.RemoteBranch) error {
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(selectedBranches)
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(selectedBranches, true)
}
func (self *RemoteBranchesController) merge(selectedBranch *models.RemoteBranch) error {