mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-19 12:12:42 +02:00
pause background threads when running subprocess
This commit is contained in:
parent
e42e7e5cbd
commit
e092da5f78
@ -104,6 +104,11 @@ type Gui struct {
|
|||||||
ViewsSetup bool
|
ViewsSetup bool
|
||||||
|
|
||||||
Views Views
|
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 {
|
type listPanelState struct {
|
||||||
@ -601,12 +606,16 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess *exec.Cmd) (bool, error) {
|
|||||||
return false, gui.surfaceError(err)
|
return false, gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui.PauseBackgroundThreads = true
|
||||||
|
|
||||||
cmdErr := gui.runSubprocess(subprocess)
|
cmdErr := gui.runSubprocess(subprocess)
|
||||||
|
|
||||||
if err := gui.g.Resume(); err != nil {
|
if err := gui.g.Resume(); err != nil {
|
||||||
return false, gui.surfaceError(err)
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui.PauseBackgroundThreads = false
|
||||||
|
|
||||||
return cmdErr == nil, gui.surfaceError(cmdErr)
|
return cmdErr == nil, gui.surfaceError(cmdErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,6 +695,9 @@ func (gui *Gui) goEvery(interval time.Duration, stop chan struct{}, function fun
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
if gui.PauseBackgroundThreads {
|
||||||
|
continue
|
||||||
|
}
|
||||||
_ = function()
|
_ = function()
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user