1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-05 00:59:19 +02:00

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
2025-07-04 17:04:00 +02:00
parent 80a614d330
commit 4b33efffbe
3 changed files with 6 additions and 3 deletions

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 { remoteBranches := lo.Map(branches, func(branch *models.Branch, _ int) *models.RemoteBranch {
return &models.RemoteBranch{Name: branch.UpstreamBranch, RemoteName: branch.UpstreamRemote} 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 { func (self *BranchesController) localAndRemoteDelete(branches []*models.Branch) error {

View File

@ -82,7 +82,7 @@ func (self *BranchesHelper) ConfirmLocalDelete(branches []*models.Branch) error
return nil return nil
} }
func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteBranch) error { func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteBranch, resetRemoteBranchesSelection bool) error {
var title string var title string
if len(remoteBranches) == 1 { if len(remoteBranches) == 1 {
title = utils.ResolvePlaceholderString( title = utils.ResolvePlaceholderString(
@ -115,6 +115,9 @@ func (self *BranchesHelper) ConfirmDeleteRemote(remoteBranches []*models.RemoteB
return err return err
} }
self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}}) self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
if resetRemoteBranchesSelection {
self.c.Contexts().RemoteBranches.CollapseRangeSelectionToTop()
}
return nil return nil
}) })
}, },

View File

@ -133,7 +133,7 @@ func (self *RemoteBranchesController) context() *context.RemoteBranchesContext {
} }
func (self *RemoteBranchesController) delete(selectedBranches []*models.RemoteBranch) error { 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 { func (self *RemoteBranchesController) merge(selectedBranch *models.RemoteBranch) error {