From 98335361fd10258e5552657b81c419500a754c39 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 8 Aug 2024 10:18:37 +0200 Subject: [PATCH] Replace PopContext() with Context().Pop() --- pkg/gui/context/menu_context.go | 2 +- pkg/gui/controllers/helpers/commits_helper.go | 2 +- pkg/gui/controllers/helpers/confirmation_helper.go | 2 +- pkg/gui/controllers/helpers/patch_building_helper.go | 2 +- pkg/gui/controllers/helpers/search_helper.go | 8 ++++---- pkg/gui/controllers/menu_controller.go | 2 +- pkg/gui/controllers/merge_conflicts_controller.go | 2 +- pkg/gui/controllers/staging_controller.go | 2 +- pkg/gui/extras_panel.go | 2 +- pkg/gui/gui_common.go | 4 ---- pkg/gui/types/common.go | 1 - 11 files changed, 12 insertions(+), 17 deletions(-) diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go index f1438b221..06cdf8b46 100644 --- a/pkg/gui/context/menu_context.go +++ b/pkg/gui/context/menu_context.go @@ -197,7 +197,7 @@ func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error { return nil } - if err := self.c.PopContext(); err != nil { + if err := self.c.Context().Pop(); err != nil { return err } diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 814ebf917..ff6ba2e80 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -193,7 +193,7 @@ func (self *CommitsHelper) CloseCommitMessagePanel() error { self.c.Views().CommitMessage.Visible = false self.c.Views().CommitDescription.Visible = false - return self.c.PopContext() + return self.c.Context().Pop() } func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error { diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index de2c493b3..330b9e77d 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -28,7 +28,7 @@ func (self *ConfirmationHelper) wrappedConfirmationFunction(cancel goContext.Can return func() error { cancel() - if err := self.c.PopContext(); err != nil { + if err := self.c.Context().Pop(); err != nil { return err } diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go index dd4c3515a..23ab9e7d1 100644 --- a/pkg/gui/controllers/helpers/patch_building_helper.go +++ b/pkg/gui/controllers/helpers/patch_building_helper.go @@ -34,7 +34,7 @@ func (self *PatchBuildingHelper) ValidateNormalWorkingTreeState() (bool, error) // takes us from the patch building panel back to the commit files panel func (self *PatchBuildingHelper) Escape() error { - return self.c.PopContext() + return self.c.Context().Pop() } // kills the custom patch and returns us back to the commit files panel if needed diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 2d958f162..cb6a47bdf 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -118,7 +118,7 @@ func (self *SearchHelper) Confirm() error { case types.SearchTypeSearch: return self.ConfirmSearch() case types.SearchTypeNone: - return self.c.PopContext() + return self.c.Context().Pop() } return nil @@ -140,7 +140,7 @@ func (self *SearchHelper) ConfirmFilter() error { context.GetSearchHistory().Push(filterString) } - return self.c.PopContext() + return self.c.Context().Pop() } func (self *SearchHelper) ConfirmSearch() error { @@ -158,7 +158,7 @@ func (self *SearchHelper) ConfirmSearch() error { context.GetSearchHistory().Push(searchString) } - if err := self.c.PopContext(); err != nil { + if err := self.c.Context().Pop(); err != nil { return err } @@ -183,7 +183,7 @@ func modelSearchResults(context types.ISearchableContext) []gocui.SearchPosition func (self *SearchHelper) CancelPrompt() error { self.Cancel() - return self.c.PopContext() + return self.c.Context().Pop() } func (self *SearchHelper) ScrollHistory(scrollIncrement int) { diff --git a/pkg/gui/controllers/menu_controller.go b/pkg/gui/controllers/menu_controller.go index ddd0b2c18..61bd3b960 100644 --- a/pkg/gui/controllers/menu_controller.go +++ b/pkg/gui/controllers/menu_controller.go @@ -79,7 +79,7 @@ func (self *MenuController) close() error { return nil } - return self.c.PopContext() + return self.c.Context().Pop() } func (self *MenuController) context() *context.MenuContext { diff --git a/pkg/gui/controllers/merge_conflicts_controller.go b/pkg/gui/controllers/merge_conflicts_controller.go index 1f22e62bc..7ed5762f7 100644 --- a/pkg/gui/controllers/merge_conflicts_controller.go +++ b/pkg/gui/controllers/merge_conflicts_controller.go @@ -194,7 +194,7 @@ func (self *MergeConflictsController) context() *context.MergeConflictsContext { } func (self *MergeConflictsController) Escape() error { - return self.c.PopContext() + return self.c.Context().Pop() } func (self *MergeConflictsController) HandleEditFile() error { diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index ee644a3cc..c3dcbafde 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -172,7 +172,7 @@ func (self *StagingController) Escape() error { return self.c.PostRefreshUpdate(self.context) } - return self.c.PopContext() + return self.c.Context().Pop() } func (self *StagingController) TogglePanel() error { diff --git a/pkg/gui/extras_panel.go b/pkg/gui/extras_panel.go index 8896824be..3534dcc69 100644 --- a/pkg/gui/extras_panel.go +++ b/pkg/gui/extras_panel.go @@ -17,7 +17,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error { OnPress: func() error { currentContext := gui.c.CurrentStaticContext() if gui.c.State().GetShowExtrasWindow() && currentContext.GetKey() == context.COMMAND_LOG_CONTEXT_KEY { - if err := gui.c.PopContext(); err != nil { + if err := gui.c.Context().Pop(); err != nil { return err } } diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index 1424ac472..da2807eb1 100644 --- a/pkg/gui/gui_common.go +++ b/pkg/gui/gui_common.go @@ -45,10 +45,6 @@ func (self *guiCommon) RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) { return self.gui.runSubprocessWithSuspense(cmdObj) } -func (self *guiCommon) PopContext() error { - return self.gui.State.ContextMgr.Pop() -} - func (self *guiCommon) ReplaceContext(context types.Context) error { return self.gui.State.ContextMgr.Replace(context) } diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 4fb888fd3..51005f671 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -57,7 +57,6 @@ type IGuiCommon interface { RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) RunSubprocessAndRefresh(oscommands.ICmdObj) error - PopContext() error ReplaceContext(context Context) error // Removes all given contexts from the stack. If a given context is not in the stack, it is ignored. // This is for when you have a group of contexts that are bundled together e.g. with the commit message panel.