diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 2b2c709f3..e1c8c8c5a 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -354,7 +354,7 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode } } - return self.c.PushContext(self.c.Contexts().CustomPatchBuilder, opts) + return self.c.Context().Push(self.c.Contexts().CustomPatchBuilder, opts) } if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.To != self.context().GetRef().RefName() { diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index 867e4528a..efcdab02b 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -220,7 +220,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error { if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil { return err } - return self.c.PushContext(self.c.Contexts().LocalCommits) + return self.c.Context().Push(self.c.Contexts().LocalCommits) }) }, }, diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 39730ae09..934aca511 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -500,7 +500,7 @@ func (self *FilesController) EnterFile(opts types.OnFocusOpts) error { return errors.New(self.c.Tr.FileStagingRequirements) } - return self.c.PushContext(self.c.Contexts().Staging, opts) + return self.c.Context().Push(self.c.Contexts().Staging, opts) } func (self *FilesController) toggleStagedAll() error { diff --git a/pkg/gui/controllers/filtering_menu_action.go b/pkg/gui/controllers/filtering_menu_action.go index a340c3e9a..51f2572e9 100644 --- a/pkg/gui/controllers/filtering_menu_action.go +++ b/pkg/gui/controllers/filtering_menu_action.go @@ -116,7 +116,7 @@ func (self *FilteringMenuAction) setFiltering() error { repoState.SetScreenMode(types.SCREEN_HALF) } - if err := self.c.PushContext(self.c.Contexts().LocalCommits); err != nil { + if err := self.c.Context().Push(self.c.Contexts().LocalCommits); err != nil { return err } diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index be3a36e8d..814ebf917 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -154,7 +154,7 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp self.UpdateCommitPanelView(opts.InitialMessage) - return self.c.PushContext(self.c.Contexts().CommitMessage) + return self.c.Context().Push(self.c.Contexts().CommitMessage) } func (self *CommitsHelper) OnCommitSuccess() { diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index c0fb5bafb..de2c493b3 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -241,7 +241,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ self.c.State().GetRepoState().SetCurrentPopupOpts(&opts) - return self.c.PushContext(self.c.Contexts().Confirmation) + return self.c.Context().Push(self.c.Contexts().Confirmation) } func underlineLinks(text string) string { diff --git a/pkg/gui/controllers/helpers/fixup_helper.go b/pkg/gui/controllers/helpers/fixup_helper.go index 9cb951408..8fc94243d 100644 --- a/pkg/gui/controllers/helpers/fixup_helper.go +++ b/pkg/gui/controllers/helpers/fixup_helper.go @@ -137,7 +137,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error { } self.c.Contexts().LocalCommits.SetSelection(index) - return self.c.PushContext(self.c.Contexts().LocalCommits) + return self.c.Context().Push(self.c.Contexts().LocalCommits) } if warnAboutAddedLines { diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index a5554aa58..73c345070 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -202,7 +202,7 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error { { Label: self.c.Tr.ViewConflictsMenuItem, OnPress: func() error { - return self.c.PushContext(self.c.Contexts().Files) + return self.c.Context().Push(self.c.Contexts().Files) }, }, { @@ -316,7 +316,7 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { if err = self.ResetMarkedBaseCommit(); err != nil { return err } - return self.c.PushContext(self.c.Contexts().LocalCommits) + return self.c.Context().Push(self.c.Contexts().LocalCommits) }, }, { diff --git a/pkg/gui/controllers/helpers/merge_conflicts_helper.go b/pkg/gui/controllers/helpers/merge_conflicts_helper.go index 249be4b69..f49f46428 100644 --- a/pkg/gui/controllers/helpers/merge_conflicts_helper.go +++ b/pkg/gui/controllers/helpers/merge_conflicts_helper.go @@ -62,7 +62,7 @@ func (self *MergeConflictsHelper) EscapeMerge() error { // files context over it. // So long as both places call OnUIThread, we're fine. if self.c.IsCurrentContext(self.c.Contexts().MergeConflicts) { - return self.c.PushContext(self.c.Contexts().Files) + return self.c.Context().Push(self.c.Contexts().Files) } return nil }) @@ -93,7 +93,7 @@ func (self *MergeConflictsHelper) SwitchToMerge(path string) error { } } - return self.c.PushContext(self.c.Contexts().MergeConflicts) + return self.c.Context().Push(self.c.Contexts().MergeConflicts) } func (self *MergeConflictsHelper) context() *context.MergeConflictsContext { diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index f471f57e2..2643ba968 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -110,7 +110,7 @@ func (self *RefsHelper) CheckoutRemoteBranch(fullBranchName string, localBranchN // Switch to the branches context _before_ starting to check out the // branch, so that we see the inline status if self.c.CurrentContext() != self.c.Contexts().Branches { - if err := self.c.PushContext(self.c.Contexts().Branches); err != nil { + if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil { return err } } @@ -293,7 +293,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest } if self.c.CurrentContext() != self.c.Contexts().Branches { - if err := self.c.PushContext(self.c.Contexts().Branches); err != nil { + if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil { return err } } diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 653640e02..2d958f162 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -41,7 +41,7 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err self.OnPromptContentChanged("") promptView.RenderTextArea() - if err := self.c.PushContext(self.c.Contexts().Search); err != nil { + if err := self.c.Context().Push(self.c.Contexts().Search); err != nil { return err } @@ -60,7 +60,7 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err promptView.ClearTextArea() promptView.RenderTextArea() - if err := self.c.PushContext(self.c.Contexts().Search); err != nil { + if err := self.c.Context().Push(self.c.Contexts().Search); err != nil { return err } diff --git a/pkg/gui/controllers/helpers/staging_helper.go b/pkg/gui/controllers/helpers/staging_helper.go index bf4424907..9e0e3d73b 100644 --- a/pkg/gui/controllers/helpers/staging_helper.go +++ b/pkg/gui/controllers/helpers/staging_helper.go @@ -83,11 +83,11 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro } if mainState == nil && !secondaryFocused { - return self.c.PushContext(secondaryContext, focusOpts) + return self.c.Context().Push(secondaryContext, focusOpts) } if secondaryState == nil && secondaryFocused { - return self.c.PushContext(mainContext, focusOpts) + return self.c.Context().Push(mainContext, focusOpts) } if secondaryFocused { @@ -110,7 +110,7 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro } func (self *StagingHelper) handleStagingEscape() error { - return self.c.PushContext(self.c.Contexts().Files) + return self.c.Context().Push(self.c.Contexts().Files) } func (self *StagingHelper) secondaryStagingFocused() bool { diff --git a/pkg/gui/controllers/helpers/sub_commits_helper.go b/pkg/gui/controllers/helpers/sub_commits_helper.go index f1cecf7f5..805aca5f1 100644 --- a/pkg/gui/controllers/helpers/sub_commits_helper.go +++ b/pkg/gui/controllers/helpers/sub_commits_helper.go @@ -72,5 +72,5 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error { return err } - return self.c.PushContext(self.c.Contexts().SubCommits) + return self.c.Context().Push(self.c.Contexts().SubCommits) } diff --git a/pkg/gui/controllers/jump_to_side_window_controller.go b/pkg/gui/controllers/jump_to_side_window_controller.go index 1a0f5afa4..2ef74d957 100644 --- a/pkg/gui/controllers/jump_to_side_window_controller.go +++ b/pkg/gui/controllers/jump_to_side_window_controller.go @@ -55,6 +55,6 @@ func (self *JumpToSideWindowController) goToSideWindow(window string) func() err context := self.c.Helpers().Window.GetContextForWindow(window) - return self.c.PushContext(context) + return self.c.Context().Push(context) } } diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go index 711d32f79..9fb8f95ec 100644 --- a/pkg/gui/controllers/list_controller.go +++ b/pkg/gui/controllers/list_controller.go @@ -176,7 +176,7 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error { func (self *ListController) pushContextIfNotFocused() error { if !self.isFocused() { - if err := self.c.PushContext(self.context); err != nil { + if err := self.c.Context().Push(self.context); err != nil { return err } } diff --git a/pkg/gui/controllers/patch_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index d75fe060d..e96ea0aa4 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -150,7 +150,7 @@ func (self *PatchExplorerController) GetMouseKeybindings(opts types.KeybindingsO return self.withRenderAndFocus(self.HandleMouseDown)() } - return self.c.PushContext(self.context, types.OnFocusOpts{ + return self.c.Context().Push(self.context, types.OnFocusOpts{ ClickedWindowName: self.context.GetWindowName(), ClickedViewLineIdx: opts.Y, }) diff --git a/pkg/gui/controllers/quit_actions.go b/pkg/gui/controllers/quit_actions.go index 7b1ba4c2d..761ef1286 100644 --- a/pkg/gui/controllers/quit_actions.go +++ b/pkg/gui/controllers/quit_actions.go @@ -74,7 +74,7 @@ func (self *QuitActions) Escape() error { parentContext, hasParent := currentContext.GetParentContext() if hasParent && currentContext != nil && parentContext != nil { // TODO: think about whether this should be marked as a return rather than adding to the stack - return self.c.PushContext(parentContext) + return self.c.Context().Push(parentContext) } for _, mode := range self.c.Helpers().Mode.Statuses() { diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index bf47a20cd..cf9c40b22 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -131,7 +131,7 @@ func (self *RemotesController) enter(remote *models.Remote) error { return err } - return self.c.PushContext(remoteBranchesContext) + return self.c.Context().Push(remoteBranchesContext) } func (self *RemotesController) add() error { diff --git a/pkg/gui/controllers/side_window_controller.go b/pkg/gui/controllers/side_window_controller.go index 0b9877494..5ad776633 100644 --- a/pkg/gui/controllers/side_window_controller.go +++ b/pkg/gui/controllers/side_window_controller.go @@ -69,7 +69,7 @@ func (self *SideWindowController) previousSideWindow() error { context := self.c.Helpers().Window.GetContextForWindow(newWindow) - return self.c.PushContext(context) + return self.c.Context().Push(context) } func (self *SideWindowController) nextSideWindow() error { @@ -92,5 +92,5 @@ func (self *SideWindowController) nextSideWindow() error { context := self.c.Helpers().Window.GetContextForWindow(newWindow) - return self.c.PushContext(context) + return self.c.Context().Push(context) } diff --git a/pkg/gui/controllers/snake_controller.go b/pkg/gui/controllers/snake_controller.go index b8e3327f7..086e42e1d 100644 --- a/pkg/gui/controllers/snake_controller.go +++ b/pkg/gui/controllers/snake_controller.go @@ -75,5 +75,5 @@ func (self *SnakeController) SetDirection(direction snake.Direction) func() erro } func (self *SnakeController) Escape() error { - return self.c.PushContext(self.c.Contexts().Submodules) + return self.c.Context().Push(self.c.Contexts().Submodules) } diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 8854aa239..ee644a3cc 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -177,7 +177,7 @@ func (self *StagingController) Escape() error { func (self *StagingController) TogglePanel() error { if self.otherContext.GetState() != nil { - return self.c.PushContext(self.otherContext) + return self.c.Context().Push(self.otherContext) } return nil diff --git a/pkg/gui/controllers/status_controller.go b/pkg/gui/controllers/status_controller.go index 483acdda6..cdfa08257 100644 --- a/pkg/gui/controllers/status_controller.go +++ b/pkg/gui/controllers/status_controller.go @@ -113,7 +113,7 @@ func (self *StatusController) onClick(opts gocui.ViewMouseBindingOpts) error { return nil } - if err := self.c.PushContext(self.Context()); err != nil { + if err := self.c.Context().Push(self.Context()); err != nil { return err } diff --git a/pkg/gui/controllers/submodules_controller.go b/pkg/gui/controllers/submodules_controller.go index ba6db6250..af729cea8 100644 --- a/pkg/gui/controllers/submodules_controller.go +++ b/pkg/gui/controllers/submodules_controller.go @@ -285,7 +285,7 @@ func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) erro } func (self *SubmodulesController) easterEgg() error { - return self.c.PushContext(self.c.Contexts().Snake) + return self.c.Context().Push(self.c.Contexts().Snake) } func (self *SubmodulesController) context() *context.SubmodulesContext { diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index 284fbd42f..92faefb79 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -89,7 +89,7 @@ func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesConte return err } - return self.c.PushContext(diffFilesContext) + return self.c.Context().Push(diffFilesContext) } func (self *SwitchToDiffFilesController) itemRepresentsCommit(ref types.Ref) *types.DisabledReason { diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index 623ef7217..9c477be8e 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -115,7 +115,7 @@ func (self *TagsController) checkout(tag *models.Tag) error { if err := self.c.Helpers().Refs.CheckoutRef(tag.FullRefName(), types.CheckoutRefOptions{}); err != nil { return err } - return self.c.PushContext(self.c.Contexts().Branches) + return self.c.Context().Push(self.c.Contexts().Branches) } func (self *TagsController) localDelete(tag *models.Tag) error { diff --git a/pkg/gui/extras_panel.go b/pkg/gui/extras_panel.go index 1d42f3c92..8896824be 100644 --- a/pkg/gui/extras_panel.go +++ b/pkg/gui/extras_panel.go @@ -40,7 +40,7 @@ func (gui *Gui) handleFocusCommandLog() error { gui.c.State().SetShowExtrasWindow(true) // TODO: is this necessary? Can't I just call 'return from context'? gui.State.Contexts.CommandLog.SetParentContext(gui.c.CurrentSideContext()) - return gui.c.PushContext(gui.State.Contexts.CommandLog) + return gui.c.Context().Push(gui.State.Contexts.CommandLog) } func (gui *Gui) scrollUpExtra() error { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 66fe5cb9c..a7cb506c5 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -335,7 +335,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context } } - if err := gui.c.PushContext(contextToPush); err != nil { + if err := gui.c.Context().Push(contextToPush); err != nil { return err } diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index 8a537f2ca..1424ac472 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) PushContext(context types.Context, opts ...types.OnFocusOpts) error { - return self.gui.State.ContextMgr.Push(context, opts...) -} - func (self *guiCommon) PopContext() error { return self.gui.State.ContextMgr.Pop() } diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index ca03ea69e..e21e32428 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -60,5 +60,5 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error { _ = gui.c.PostRefreshUpdate(gui.State.Contexts.Menu) // TODO: ensure that if we're opened a menu from within a menu that it renders correctly - return gui.c.PushContext(gui.State.Contexts.Menu) + return gui.c.Context().Push(gui.State.Contexts.Menu) } diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index c6885d717..4fb888fd3 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 - PushContext(context Context, opts ...OnFocusOpts) 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. diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 1043920ec..deb283fc6 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -78,7 +78,7 @@ func (gui *Gui) onViewTabClick(windowName string, tabIndex int) error { return nil } - return gui.c.PushContext(context) + return gui.c.Context().Push(context) } func (gui *Gui) handleNextTab() error {