mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Ensure background refreshes don't bunch up
This commit is contained in:
		| @@ -77,6 +77,7 @@ func (self *BackgroundRoutineMgr) startBackgroundFilesRefresh(refreshInterval in | ||||
| } | ||||
|  | ||||
| func (self *BackgroundRoutineMgr) goEvery(interval time.Duration, stop chan struct{}, function func() error) { | ||||
| 	done := make(chan struct{}) | ||||
| 	go utils.Safe(func() { | ||||
| 		ticker := time.NewTicker(interval) | ||||
| 		defer ticker.Stop() | ||||
| @@ -86,7 +87,12 @@ func (self *BackgroundRoutineMgr) goEvery(interval time.Duration, stop chan stru | ||||
| 				if self.pauseBackgroundRefreshes { | ||||
| 					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: | ||||
| 				return | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user