1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

Fix flakey misc/initial_open test

I've simplifiied the code because it was too complex for the current requirements, and this fixed the misc/initial_open
test which was occasionally failing due to a race condition around busy tasks
This commit is contained in:
Jesse Duffield 2023-07-10 13:05:49 +10:00
parent a0154dc525
commit c05a1ae711
2 changed files with 14 additions and 30 deletions

View File

@ -780,37 +780,23 @@ func (gui *Gui) loadNewRepo() error {
return nil
}
func (gui *Gui) showInitialPopups(popupTasks []func(chan struct{}) error) {
gui.waitForIntro.Add(len(popupTasks))
done := make(chan struct{})
func (gui *Gui) showIntroPopupMessage() {
gui.waitForIntro.Add(1)
gui.c.OnWorker(func(task gocui.Task) {
for _, popupTask := range popupTasks {
if err := popupTask(done); err != nil {
_ = gui.c.Error(err)
}
task.Pause()
<-done
task.Continue()
gui.c.OnUIThread(func() error {
onConfirm := func() error {
gui.c.GetAppState().StartupPopupVersion = StartupPopupVersion
err := gui.c.SaveAppState()
gui.waitForIntro.Done()
return err
}
})
}
func (gui *Gui) showIntroPopupMessage(done chan struct{}) error {
onConfirm := func() error {
gui.c.GetAppState().StartupPopupVersion = StartupPopupVersion
err := gui.c.SaveAppState()
done <- struct{}{}
return err
}
return gui.c.Confirm(types.ConfirmOpts{
Title: "",
Prompt: gui.c.Tr.IntroPopupMessage,
HandleConfirm: onConfirm,
HandleClose: onConfirm,
return gui.c.Confirm(types.ConfirmOpts{
Title: "",
Prompt: gui.c.Tr.IntroPopupMessage,
HandleConfirm: onConfirm,
HandleClose: onConfirm,
})
})
}

View File

@ -213,12 +213,10 @@ func (gui *Gui) onInitialViewsCreation() error {
gui.g.Mutexes.ViewsMutex.Unlock()
if !gui.c.UserConfig.DisableStartupPopups {
popupTasks := []func(chan struct{}) error{}
storedPopupVersion := gui.c.GetAppState().StartupPopupVersion
if storedPopupVersion < StartupPopupVersion {
popupTasks = append(popupTasks, gui.showIntroPopupMessage)
gui.showIntroPopupMessage()
}
gui.showInitialPopups(popupTasks)
}
if gui.showRecentRepos {