From 240483953f708f538b3396fa9e21069c1461137c Mon Sep 17 00:00:00 2001 From: Moritz Haase Date: Sat, 26 Mar 2022 18:10:58 +0100 Subject: config: Add option 'git.autoRefresh' to en-/disable auto-refresh Adds a new 'autoRefresh' option to the 'git' config section that allows user to disable auto-refresh (defaults to on). If auto-refresh is enabled, the refreshInterval is now checked before starting the timer to prevent crashes when it is non-positive. Fixes #1417 --- pkg/gui/gui.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'pkg/gui/gui.go') diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index b4e0f8de4..3848f2bd9 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -587,7 +587,16 @@ func (gui *Gui) Run(filterPath string) error { go utils.Safe(gui.startBackgroundFetch) } - gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules) + if userConfig.Git.AutoRefresh { + refreshInterval := userConfig.Refresher.RefreshInterval + if refreshInterval > 0 { + gui.goEvery(time.Second*time.Duration(refreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules) + } else { + gui.c.Log.Errorf( + "Value of config option 'refresher.refreshInterval' (%d) is invalid, disabling auto-refresh", + refreshInterval) + } + } gui.c.Log.Info("starting main loop") -- cgit v1.2.3