mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-01 13:17:53 +02:00
Ensure background refreshes don't bunch up
This commit is contained in:
parent
90613056ce
commit
d44d164a5a
@ -77,6 +77,7 @@ func (self *BackgroundRoutineMgr) startBackgroundFilesRefresh(refreshInterval in
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *BackgroundRoutineMgr) goEvery(interval time.Duration, stop chan struct{}, function func() error) {
|
func (self *BackgroundRoutineMgr) goEvery(interval time.Duration, stop chan struct{}, function func() error) {
|
||||||
|
done := make(chan struct{})
|
||||||
go utils.Safe(func() {
|
go utils.Safe(func() {
|
||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
@ -86,7 +87,12 @@ func (self *BackgroundRoutineMgr) goEvery(interval time.Duration, stop chan stru
|
|||||||
if self.pauseBackgroundRefreshes {
|
if self.pauseBackgroundRefreshes {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
self.gui.c.OnWorker(func(gocui.Task) { _ = function() })
|
self.gui.c.OnWorker(func(gocui.Task) {
|
||||||
|
_ = function()
|
||||||
|
done <- struct{}{}
|
||||||
|
})
|
||||||
|
// waiting so that we don't bunch up refreshes if the refresh takes longer than the interval
|
||||||
|
<-done
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user