1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

add some safe goroutines

WIP
This commit is contained in:
Jesse Duffield
2020-10-07 21:19:38 +11:00
parent ba4c3e5bc4
commit 79e59d5460
15 changed files with 84 additions and 64 deletions

View File

@@ -50,14 +50,14 @@ func (m *statusManager) getStatusString() string {
// WithWaitingStatus wraps a function and shows a waiting status while the function is still executing
func (gui *Gui) WithWaitingStatus(name string, f func() error) error {
go func() {
go utils.Safe(func() {
gui.statusManager.addWaitingStatus(name)
defer func() {
gui.statusManager.removeStatus(name)
}()
go func() {
go utils.Safe(func() {
ticker := time.NewTicker(time.Millisecond * 50)
defer ticker.Stop()
for range ticker.C {
@@ -67,14 +67,14 @@ func (gui *Gui) WithWaitingStatus(name string, f func() error) error {
}
gui.renderString("appStatus", appStatus)
}
}()
})
if err := f(); err != nil {
gui.g.Update(func(g *gocui.Gui) error {
return gui.surfaceError(err)
})
}
}()
})
return nil
}