From df3afb1b89a38ec94ea99693fe8f19fba4a4e398 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 8 Aug 2024 10:29:36 +0200 Subject: [PATCH] Replace CurrentSideContext() with Context().CurrentSide() --- pkg/gui/controllers/filtering_menu_action.go | 2 +- pkg/gui/controllers/helpers/diff_helper.go | 2 +- pkg/gui/controllers/helpers/window_arrangement_helper.go | 2 +- pkg/gui/controllers/toggle_whitespace_action.go | 2 +- pkg/gui/extras_panel.go | 2 +- pkg/gui/global_handlers.go | 4 ++-- pkg/gui/gui_common.go | 4 ---- pkg/gui/types/common.go | 1 - 8 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pkg/gui/controllers/filtering_menu_action.go b/pkg/gui/controllers/filtering_menu_action.go index 51f2572e9..9367c5bca 100644 --- a/pkg/gui/controllers/filtering_menu_action.go +++ b/pkg/gui/controllers/filtering_menu_action.go @@ -14,7 +14,7 @@ type FilteringMenuAction struct { func (self *FilteringMenuAction) Call() error { fileName := "" author := "" - switch self.c.CurrentSideContext() { + switch self.c.Context().CurrentSide() { case self.c.Contexts().Files: node := self.c.Contexts().Files.GetSelected() if node != nil { diff --git a/pkg/gui/controllers/helpers/diff_helper.go b/pkg/gui/controllers/helpers/diff_helper.go index ad46a589c..94ac291b9 100644 --- a/pkg/gui/controllers/helpers/diff_helper.go +++ b/pkg/gui/controllers/helpers/diff_helper.go @@ -70,7 +70,7 @@ func (self *DiffHelper) RenderDiff() error { // which becomes an option when you bring up the diff menu, but when you're just // flicking through branches it will be using the local branch name. func (self *DiffHelper) CurrentDiffTerminals() []string { - c := self.c.CurrentSideContext() + c := self.c.Context().CurrentSide() if c.GetKey() == "" { return nil diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 633ccd8cf..d27e9aa82 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -89,7 +89,7 @@ func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, Height: height, UserConfig: self.c.UserConfig, CurrentWindow: self.windowHelper.CurrentWindow(), - CurrentSideWindow: self.c.CurrentSideContext().GetWindowName(), + CurrentSideWindow: self.c.Context().CurrentSide().GetWindowName(), CurrentStaticWindow: self.c.Context().CurrentStatic().GetWindowName(), SplitMainPanel: repoState.GetSplitMainPanel(), ScreenMode: repoState.GetScreenMode(), diff --git a/pkg/gui/controllers/toggle_whitespace_action.go b/pkg/gui/controllers/toggle_whitespace_action.go index 59d09fa98..f5362ddf4 100644 --- a/pkg/gui/controllers/toggle_whitespace_action.go +++ b/pkg/gui/controllers/toggle_whitespace_action.go @@ -28,5 +28,5 @@ func (self *ToggleWhitespaceAction) Call() error { self.c.GetAppState().IgnoreWhitespaceInDiffView = !self.c.GetAppState().IgnoreWhitespaceInDiffView self.c.SaveAppStateAndLogError() - return self.c.CurrentSideContext().HandleFocus(types.OnFocusOpts{}) + return self.c.Context().CurrentSide().HandleFocus(types.OnFocusOpts{}) } diff --git a/pkg/gui/extras_panel.go b/pkg/gui/extras_panel.go index 1083b7ea9..e3d8998d6 100644 --- a/pkg/gui/extras_panel.go +++ b/pkg/gui/extras_panel.go @@ -39,7 +39,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error { 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()) + gui.State.Contexts.CommandLog.SetParentContext(gui.c.Context().CurrentSide()) return gui.c.Context().Push(gui.State.Contexts.CommandLog) } diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index 5d4e886bf..98089321e 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -128,7 +128,7 @@ func (gui *Gui) handleCopySelectedSideContextItemCommitHashToClipboard() error { func (gui *Gui) handleCopySelectedSideContextItemToClipboardWithTruncation(maxWidth int) error { // important to note that this assumes we've selected an item in a side context - currentSideContext := gui.c.CurrentSideContext() + currentSideContext := gui.c.Context().CurrentSide() if currentSideContext == nil { return nil } @@ -162,7 +162,7 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboardWithTruncation(maxWi func (gui *Gui) getCopySelectedSideContextItemToClipboardDisabledReason() *types.DisabledReason { // important to note that this assumes we've selected an item in a side context - currentSideContext := gui.c.CurrentSideContext() + currentSideContext := gui.c.Context().CurrentSide() if currentSideContext == nil { // This should never happen but if it does we'll just ignore the keypress return nil diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index 0628c1b3b..385a86d37 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) CurrentSideContext() types.Context { - return self.gui.State.ContextMgr.CurrentSide() -} - func (self *guiCommon) CurrentPopupContexts() []types.Context { return self.gui.State.ContextMgr.PopupContexts() } diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 2a8971bd6..dd3a237f2 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 - CurrentSideContext() Context CurrentPopupContexts() []Context IsCurrentContext(Context) bool // TODO: replace the above context-based methods with just using Context() e.g. replace PushContext() with Context().Push()