Skip to content

Commit 4b33eff

Browse files
committed
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.
1 parent 80a614d commit 4b33eff

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

pkg/gui/controllers/branches_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func (self *BranchesController) remoteDelete(branches []*models.Branch) error {
535535
remoteBranches := lo.Map(branches, func(branch *models.Branch, _ int) *models.RemoteBranch {
536536
return &models.RemoteBranch{Name: branch.UpstreamBranch, RemoteName: branch.UpstreamRemote}
537537
})
538-
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(remoteBranches)
538+
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(remoteBranches, false)
539539
}
540540

541541
func (self *BranchesController) localAndRemoteDelete(branches []*models.Branch) error {

pkg/gui/controllers/helpers/branches_helper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (self *BranchesHelper) ConfirmLocalDelete(branches []*models.Branch) error
8282
return nil
8383
}
8484

85-
func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteBranch) error {
85+
func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteBranch, resetRemoteBranchesSelection bool) error {
8686
var title string
8787
if len(remoteBranches) == 1 {
8888
title = utils.ResolvePlaceholderString(
@@ -115,6 +115,9 @@ func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteB
115115
return err
116116
}
117117
self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
118+
if resetRemoteBranchesSelection {
119+
self.c.Contexts().RemoteBranches.CollapseRangeSelectionToTop()
120+
}
118121
return nil
119122
})
120123
},

pkg/gui/controllers/remote_branches_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (self *RemoteBranchesController) context() *context.RemoteBranchesContext {
133133
}
134134

135135
func (self *RemoteBranchesController) delete(selectedBranches []*models.RemoteBranch) error {
136-
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(selectedBranches)
136+
return self.c.Helpers().BranchesHelper.ConfirmDeleteRemote(selectedBranches, true)
137137
}
138138

139139
func (self *RemoteBranchesController) merge(selectedBranch *models.RemoteBranch) error {

0 commit comments

Comments
 (0)