diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-10 12:07:52 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-10 12:16:45 +1000 |
commit | e092da5f7840f40f6905043c4ab5fe871b077b36 (patch) | |
tree | f25f05cdb6795d4af3b27247e634d50976c9e19f /pkg | |
parent | e42e7e5cbd9d075ee24ae8f91ba9e12bdd42fafc (diff) |
pause background threads when running subprocessv0.27.3
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/gui.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 937b5b6e6..6955b52b1 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -104,6 +104,11 @@ type Gui struct { ViewsSetup bool Views Views + + // if we've suspended the gui (e.g. because we've switched to a subprocess) + // we typically want to pause some things that are running like background + // file refreshes + PauseBackgroundThreads bool } type listPanelState struct { @@ -601,12 +606,16 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess *exec.Cmd) (bool, error) { return false, gui.surfaceError(err) } + gui.PauseBackgroundThreads = true + cmdErr := gui.runSubprocess(subprocess) if err := gui.g.Resume(); err != nil { - return false, gui.surfaceError(err) + return false, err } + gui.PauseBackgroundThreads = false + return cmdErr == nil, gui.surfaceError(cmdErr) } @@ -686,6 +695,9 @@ func (gui *Gui) goEvery(interval time.Duration, stop chan struct{}, function fun for { select { case <-ticker.C: + if gui.PauseBackgroundThreads { + continue + } _ = function() case <-stop: return |