diff options
author | Moritz Haase <Moritz.Haase@bmw.de> | 2022-03-26 18:10:58 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-27 10:14:33 +1100 |
commit | 240483953f708f538b3396fa9e21069c1461137c (patch) | |
tree | b41fdcc02e1b128ea5d4cdd6374a5e4f48829f05 /pkg/gui/gui.go | |
parent | 51baa8c17dddd59b4640aec10758dafb586a612e (diff) |
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
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 11 |
1 files changed, 10 insertions, 1 deletions
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") |