diff --git a/pkg/gui/context.go b/pkg/gui/context.go index e4719ab13..61de2d8dc 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -78,12 +78,15 @@ func (gui *Gui) pushToContextStack(c types.Context) []types.Context { gui.State.ContextManager.ContextStack = []types.Context{c} } else if c.GetKind() == types.MAIN_CONTEXT { // if we're switching to a main context, remove all other main contexts in the stack + contextsToKeep := []types.Context{} for _, stackContext := range gui.State.ContextManager.ContextStack { if stackContext.GetKind() == types.MAIN_CONTEXT { contextsToDeactivate = append(contextsToDeactivate, stackContext) + } else { + contextsToKeep = append(contextsToKeep, stackContext) } } - gui.State.ContextManager.ContextStack = []types.Context{c} + gui.State.ContextManager.ContextStack = append(contextsToKeep, c) } else { topContext := gui.currentContextWithoutLock() diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go index 25ac63a08..646a8f167 100644 --- a/pkg/gui/controllers/helpers/patch_building_helper.go +++ b/pkg/gui/controllers/helpers/patch_building_helper.go @@ -38,7 +38,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.PushContext(self.contexts.CommitFiles) + return self.c.PopContext() } // kills the custom patch and returns us back to the commit files panel if needed diff --git a/pkg/gui/controllers/merge_conflicts_controller.go b/pkg/gui/controllers/merge_conflicts_controller.go index 90da5283c..b35f846c2 100644 --- a/pkg/gui/controllers/merge_conflicts_controller.go +++ b/pkg/gui/controllers/merge_conflicts_controller.go @@ -162,7 +162,7 @@ func (self *MergeConflictsController) context() *context.MergeConflictsContext { } func (self *MergeConflictsController) Escape() error { - return self.c.PushContext(self.contexts.Files) + return self.c.PopContext() } func (self *MergeConflictsController) HandleEditFile() error { diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 0a8ca5521..0cddfb841 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -133,7 +133,7 @@ func (self *StagingController) EditFile() error { } func (self *StagingController) Escape() error { - return self.c.PushContext(self.contexts.Files) + return self.c.PopContext() } func (self *StagingController) TogglePanel() error {