mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-02 23:27:32 +02:00
Fall back to WithWaitingStatus if view showing the item is not visible
This commit is contained in:
parent
240948b882
commit
0fd4983c66
@ -115,7 +115,7 @@ func (gui *Gui) resetHelpersAndControllers() {
|
|||||||
Confirmation: helpers.NewConfirmationHelper(helperCommon),
|
Confirmation: helpers.NewConfirmationHelper(helperCommon),
|
||||||
Mode: modeHelper,
|
Mode: modeHelper,
|
||||||
AppStatus: appStatusHelper,
|
AppStatus: appStatusHelper,
|
||||||
InlineStatus: helpers.NewInlineStatusHelper(helperCommon),
|
InlineStatus: helpers.NewInlineStatusHelper(helperCommon, windowHelper),
|
||||||
WindowArrangement: helpers.NewWindowArrangementHelper(
|
WindowArrangement: helpers.NewWindowArrangementHelper(
|
||||||
gui.c,
|
gui.c,
|
||||||
windowHelper,
|
windowHelper,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/sasha-s/go-deadlock"
|
"github.com/sasha-s/go-deadlock"
|
||||||
@ -12,13 +13,15 @@ import (
|
|||||||
type InlineStatusHelper struct {
|
type InlineStatusHelper struct {
|
||||||
c *HelperCommon
|
c *HelperCommon
|
||||||
|
|
||||||
|
windowHelper *WindowHelper
|
||||||
contextsWithInlineStatus map[types.ContextKey]*inlineStatusInfo
|
contextsWithInlineStatus map[types.ContextKey]*inlineStatusInfo
|
||||||
mutex *deadlock.Mutex
|
mutex *deadlock.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInlineStatusHelper(c *HelperCommon) *InlineStatusHelper {
|
func NewInlineStatusHelper(c *HelperCommon, windowHelper *WindowHelper) *InlineStatusHelper {
|
||||||
return &InlineStatusHelper{
|
return &InlineStatusHelper{
|
||||||
c: c,
|
c: c,
|
||||||
|
windowHelper: windowHelper,
|
||||||
contextsWithInlineStatus: make(map[types.ContextKey]*inlineStatusInfo),
|
contextsWithInlineStatus: make(map[types.ContextKey]*inlineStatusInfo),
|
||||||
mutex: &deadlock.Mutex{},
|
mutex: &deadlock.Mutex{},
|
||||||
}
|
}
|
||||||
@ -61,18 +64,33 @@ func (self inlineStatusHelperTask) Continue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *InlineStatusHelper) WithInlineStatus(opts InlineStatusOpts, f func(gocui.Task) error) {
|
func (self *InlineStatusHelper) WithInlineStatus(opts InlineStatusOpts, f func(gocui.Task) error) {
|
||||||
self.c.OnWorker(func(task gocui.Task) {
|
context := self.c.ContextForKey(opts.ContextKey)
|
||||||
self.start(opts)
|
view := context.GetView()
|
||||||
|
visible := view.Visible && self.windowHelper.TopViewInWindow(context.GetWindowName()) == view
|
||||||
|
if visible {
|
||||||
|
self.c.OnWorker(func(task gocui.Task) {
|
||||||
|
self.start(opts)
|
||||||
|
|
||||||
err := f(inlineStatusHelperTask{task, self, opts})
|
err := f(inlineStatusHelperTask{task, self, opts})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.c.OnUIThread(func() error {
|
self.c.OnUIThread(func() error {
|
||||||
return self.c.Error(err)
|
return self.c.Error(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
self.stop(opts)
|
self.stop(opts)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
message := presentation.ItemOperationToString(opts.Operation, self.c.Tr)
|
||||||
|
_ = self.c.WithWaitingStatus(message, func(t gocui.Task) error {
|
||||||
|
// We still need to set the item operation, because it might be used
|
||||||
|
// for other (non-presentation) purposes
|
||||||
|
self.c.State().SetItemOperation(opts.Item, opts.Operation)
|
||||||
|
defer self.c.State().ClearItemOperation(opts.Item)
|
||||||
|
|
||||||
|
return f(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *InlineStatusHelper) start(opts InlineStatusOpts) {
|
func (self *InlineStatusHelper) start(opts InlineStatusOpts) {
|
||||||
|
@ -163,7 +163,7 @@ func ColoredBranchStatus(branch *models.Branch, itemOperation types.ItemOperatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BranchStatus(branch *models.Branch, itemOperation types.ItemOperation, tr *i18n.TranslationSet, now time.Time) string {
|
func BranchStatus(branch *models.Branch, itemOperation types.ItemOperation, tr *i18n.TranslationSet, now time.Time) string {
|
||||||
itemOperationStr := itemOperationToString(itemOperation, tr)
|
itemOperationStr := ItemOperationToString(itemOperation, tr)
|
||||||
if itemOperationStr != "" {
|
if itemOperationStr != "" {
|
||||||
return itemOperationStr + " " + utils.Loader(now)
|
return itemOperationStr + " " + utils.Loader(now)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
)
|
)
|
||||||
|
|
||||||
func itemOperationToString(itemOperation types.ItemOperation, tr *i18n.TranslationSet) string {
|
func ItemOperationToString(itemOperation types.ItemOperation, tr *i18n.TranslationSet) string {
|
||||||
switch itemOperation {
|
switch itemOperation {
|
||||||
case types.ItemOperationNone:
|
case types.ItemOperationNone:
|
||||||
return ""
|
return ""
|
||||||
|
@ -37,7 +37,7 @@ func getTagDisplayStrings(t *models.Tag, itemOperation types.ItemOperation, diff
|
|||||||
}
|
}
|
||||||
descriptionColor := style.FgYellow
|
descriptionColor := style.FgYellow
|
||||||
descriptionStr := descriptionColor.Sprint(t.Description())
|
descriptionStr := descriptionColor.Sprint(t.Description())
|
||||||
itemOperationStr := itemOperationToString(itemOperation, tr)
|
itemOperationStr := ItemOperationToString(itemOperation, tr)
|
||||||
if itemOperationStr != "" {
|
if itemOperationStr != "" {
|
||||||
descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now())) + " " + descriptionStr
|
descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now())) + " " + descriptionStr
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user