mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-28 02:07:09 -04:00
Generalize showing an inline status on several branches to any items
Deleting and pushing a range selection of tags will need to show their operation on all the selected tags. Move the code from BranchesHelper into a generic function that takes the items and the key of the context that shows them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
02e103c873
commit
fc6ed07747
@@ -504,18 +504,7 @@ func (self *BranchesHelper) PrepareFastForward(branches []*models.Branch) (func(
|
||||
// Runs f on a worker with all the given branches shown as being in the given
|
||||
// operation while it runs
|
||||
func (self *BranchesHelper) WithInlineStatusOnBranches(branches []*models.Branch, operation types.ItemOperation, f func(gocui.Task) error) error {
|
||||
return self.c.WithInlineStatus(branches[0], operation, context.LOCAL_BRANCHES_CONTEXT_KEY, func(task gocui.Task) error {
|
||||
for _, branch := range branches[1:] {
|
||||
self.c.State().SetItemOperation(branch, operation)
|
||||
}
|
||||
defer func() {
|
||||
for _, branch := range branches[1:] {
|
||||
self.c.State().ClearItemOperation(branch)
|
||||
}
|
||||
}()
|
||||
|
||||
return f(task)
|
||||
})
|
||||
return WithInlineStatusOnItems(self.c, branches, operation, context.LOCAL_BRANCHES_CONTEXT_KEY, f)
|
||||
}
|
||||
|
||||
func (self *BranchesHelper) fetchUpstreamBranches(task gocui.Task, branches []*models.Branch) error {
|
||||
|
||||
@@ -94,6 +94,23 @@ func (self *InlineStatusHelper) WithInlineStatus(opts InlineStatusOpts, f func(g
|
||||
}
|
||||
}
|
||||
|
||||
// Runs f on a worker with all the given items shown as being in the given
|
||||
// operation while it runs
|
||||
func WithInlineStatusOnItems[T types.HasUrn](c *HelperCommon, items []T, operation types.ItemOperation, contextKey types.ContextKey, f func(gocui.Task) error) error {
|
||||
return c.WithInlineStatus(items[0], operation, contextKey, func(task gocui.Task) error {
|
||||
for _, item := range items[1:] {
|
||||
c.State().SetItemOperation(item, operation)
|
||||
}
|
||||
defer func() {
|
||||
for _, item := range items[1:] {
|
||||
c.State().ClearItemOperation(item)
|
||||
}
|
||||
}()
|
||||
|
||||
return f(task)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *InlineStatusHelper) start(opts InlineStatusOpts) {
|
||||
self.c.State().SetItemOperation(opts.Item, opts.Operation)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user