diff options
Diffstat (limited to 'pkg/gui/controllers/helpers')
-rw-r--r-- | pkg/gui/controllers/helpers/app_status_helper.go | 9 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/cherry_pick_helper.go | 3 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/gpg_helper.go | 3 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/refresh_helper.go | 7 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/refs_helper.go | 3 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/suggestions_helper.go | 3 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/update_helper.go | 5 |
7 files changed, 21 insertions, 12 deletions
diff --git a/pkg/gui/controllers/helpers/app_status_helper.go b/pkg/gui/controllers/helpers/app_status_helper.go index dcac41e48..e271e1999 100644 --- a/pkg/gui/controllers/helpers/app_status_helper.go +++ b/pkg/gui/controllers/helpers/app_status_helper.go @@ -3,6 +3,7 @@ package helpers import ( "time" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/status" ) @@ -26,12 +27,12 @@ func (self *AppStatusHelper) Toast(message string) { } // withWaitingStatus wraps a function and shows a waiting status while the function is still executing -func (self *AppStatusHelper) WithWaitingStatus(message string, f func() error) { - self.c.OnWorker(func() { +func (self *AppStatusHelper) WithWaitingStatus(message string, f func(*gocui.Task) error) { + self.c.OnWorker(func(task *gocui.Task) { self.statusMgr().WithWaitingStatus(message, func() { self.renderAppStatus() - if err := f(); err != nil { + if err := f(task); err != nil { self.c.OnUIThread(func() error { return self.c.Error(err) }) @@ -49,7 +50,7 @@ func (self *AppStatusHelper) GetStatusString() string { } func (self *AppStatusHelper) renderAppStatus() { - self.c.OnWorker(func() { + self.c.OnWorker(func(_ *gocui.Task) { ticker := time.NewTicker(time.Millisecond * 50) defer ticker.Stop() for range ticker.C { diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 2c9b7c7c9..9797b3ef3 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -1,6 +1,7 @@ package helpers import ( + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -75,7 +76,7 @@ func (self *CherryPickHelper) Paste() error { Title: self.c.Tr.CherryPick, Prompt: self.c.Tr.SureCherryPick, HandleConfirm: func() error { - return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func() error { + return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func(*gocui.Task) error { self.c.LogAction(self.c.Tr.Actions.CherryPick) err := self.c.Git().Rebase.CherryPickCommits(self.getData().CherryPickedCommits) return self.rebaseHelper.CheckMergeOrRebase(err) diff --git a/pkg/gui/controllers/helpers/gpg_helper.go b/pkg/gui/controllers/helpers/gpg_helper.go index 45d67faaf..c31e26c49 100644 --- a/pkg/gui/controllers/helpers/gpg_helper.go +++ b/pkg/gui/controllers/helpers/gpg_helper.go @@ -3,6 +3,7 @@ package helpers import ( "fmt" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -41,7 +42,7 @@ func (self *GpgHelper) WithGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus } func (self *GpgHelper) runAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error { - return self.c.WithWaitingStatus(waitingStatus, func() error { + return self.c.WithWaitingStatus(waitingStatus, func(*gocui.Task) error { if err := cmdObj.StreamOutput().Run(); err != nil { _ = self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) return self.c.Error( diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 6c9064519..15fd84375 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -7,6 +7,7 @@ import ( "github.com/jesseduffield/generics/set" "github.com/jesseduffield/generics/slices" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/types/enums" @@ -86,7 +87,9 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error { refresh := func(f func()) { if options.Mode == types.ASYNC { - self.c.OnWorker(f) + self.c.OnWorker(func(t *gocui.Task) { + f() + }) } else { f() } @@ -198,7 +201,7 @@ func getModeName(mode types.RefreshMode) string { func (self *RefreshHelper) refreshReflogCommitsConsideringStartup() { switch self.c.State().GetRepoState().GetStartupStage() { case types.INITIAL: - self.c.OnWorker(func() { + self.c.OnWorker(func(_ *gocui.Task) { _ = self.refreshReflogCommits() self.refreshBranches() self.c.State().GetRepoState().SetStartupStage(types.COMPLETE) diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 18227a35b..c59cd023c 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/jesseduffield/generics/slices" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/style" @@ -50,7 +51,7 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions self.c.Contexts().LocalCommits.SetLimitCommits(true) } - return self.c.WithWaitingStatus(waitingStatus, func() error { + return self.c.WithWaitingStatus(waitingStatus, func(*gocui.Task) error { if err := self.c.Git().Branch.Checkout(ref, cmdOptions); err != nil { // note, this will only work for english-language git commands. If we force git to use english, and the error isn't this one, then the user will receive an english command they may not understand. I'm not sure what the best solution to this is. Running the command once in english and a second time in the native language is one option diff --git a/pkg/gui/controllers/helpers/suggestions_helper.go b/pkg/gui/controllers/helpers/suggestions_helper.go index 70fcf168a..fc3a7ff70 100644 --- a/pkg/gui/controllers/helpers/suggestions_helper.go +++ b/pkg/gui/controllers/helpers/suggestions_helper.go @@ -5,6 +5,7 @@ import ( "os" "github.com/jesseduffield/generics/slices" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -100,7 +101,7 @@ func (self *SuggestionsHelper) GetBranchNameSuggestionsFunc() func(string) []*ty // Notably, unlike other suggestion functions we're not showing all the options // if nothing has been typed because there'll be too much to display efficiently func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*types.Suggestion { - _ = self.c.WithWaitingStatus(self.c.Tr.LoadingFileSuggestions, func() error { + _ = self.c.WithWaitingStatus(self.c.Tr.LoadingFileSuggestions, func(*gocui.Task) error { trie := patricia.NewTrie() // load every non-gitignored file in the repo ignore, err := gitignore.FromGit() diff --git a/pkg/gui/controllers/helpers/update_helper.go b/pkg/gui/controllers/helpers/update_helper.go index ea9be8f16..20d55849d 100644 --- a/pkg/gui/controllers/helpers/update_helper.go +++ b/pkg/gui/controllers/helpers/update_helper.go @@ -1,6 +1,7 @@ package helpers import ( + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/updates" "github.com/jesseduffield/lazygit/pkg/utils" @@ -37,7 +38,7 @@ func (self *UpdateHelper) CheckForUpdateInBackground() { } func (self *UpdateHelper) CheckForUpdateInForeground() error { - return self.c.WithWaitingStatus(self.c.Tr.CheckingForUpdates, func() error { + return self.c.WithWaitingStatus(self.c.Tr.CheckingForUpdates, func(*gocui.Task) error { self.updater.CheckForNewUpdate(func(newVersion string, err error) error { if err != nil { return self.c.Error(err) @@ -53,7 +54,7 @@ func (self *UpdateHelper) CheckForUpdateInForeground() error { } func (self *UpdateHelper) startUpdating(newVersion string) { - _ = self.c.WithWaitingStatus(self.c.Tr.UpdateInProgressWaitingStatus, func() error { + _ = self.c.WithWaitingStatus(self.c.Tr.UpdateInProgressWaitingStatus, func(*gocui.Task) error { self.c.State().SetUpdating(true) err := self.updater.Update(newVersion) return self.onUpdateFinish(err) |