From 8e15451117acfe866226779542609d024cc40b33 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 8 Aug 2024 10:23:01 +0200 Subject: [PATCH] Remove unused method RemoveContexts() --- pkg/gui/context.go | 30 ------------------------------ pkg/gui/gui_common.go | 4 ---- pkg/gui/types/common.go | 4 ---- 3 files changed, 38 deletions(-) diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 5dc6df6a0..6ee055f80 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -167,36 +167,6 @@ func (self *ContextMgr) Pop() error { return self.ActivateContext(newContext, types.OnFocusOpts{}) } -func (self *ContextMgr) RemoveContexts(contextsToRemove []types.Context) error { - self.Lock() - - if len(self.ContextStack) == 1 { - self.Unlock() - return nil - } - - rest := lo.Filter(self.ContextStack, func(context types.Context, _ int) bool { - for _, contextToRemove := range contextsToRemove { - if context.GetKey() == contextToRemove.GetKey() { - return false - } - } - return true - }) - self.ContextStack = rest - contextToActivate := rest[len(rest)-1] - self.Unlock() - - for _, context := range contextsToRemove { - if err := self.deactivateContext(context, types.OnFocusLostOpts{NewContextKey: contextToActivate.GetKey()}); err != nil { - return err - } - } - - // activate the item at the top of the stack - return self.ActivateContext(contextToActivate, types.OnFocusOpts{}) -} - func (self *ContextMgr) deactivateContext(c types.Context, opts types.OnFocusLostOpts) error { view, _ := self.gui.c.GocuiGui().View(c.GetViewName()) diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index 731b0073b..09ef709d3 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) RemoveContexts(contexts []types.Context) error { - return self.gui.State.ContextMgr.RemoveContexts(contexts) -} - func (self *guiCommon) CurrentContext() types.Context { return self.gui.State.ContextMgr.Current() } diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 8ece954a7..bbb106ae0 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -57,10 +57,6 @@ type IGuiCommon interface { RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) RunSubprocessAndRefresh(oscommands.ICmdObj) 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. - // If you want to remove a single context, you should probably use PopContext instead. - RemoveContexts([]Context) error CurrentContext() Context CurrentStaticContext() Context CurrentSideContext() Context