summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-03-06 17:32:28 +1100
committerGitHub <noreply@github.com>2023-03-06 17:32:28 +1100
commit3791b5057af85b7ec14e6931081202b3454d6c5d (patch)
treeb2179df6d685d8fda94379c0b5f17caca0258a27
parent40a29fd622df85094f9982426437b30d0b603abc (diff)
parent723504a290ca208c5ee8dc67c86b69b98cfbd069 (diff)
Merge pull request #2481 from stefanhaller/fix-accordion-mode-for-custom-patch
-rw-r--r--pkg/gui/context.go5
-rw-r--r--pkg/gui/controllers/helpers/patch_building_helper.go2
-rw-r--r--pkg/gui/controllers/merge_conflicts_controller.go2
-rw-r--r--pkg/gui/controllers/staging_controller.go2
4 files changed, 7 insertions, 4 deletions
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 {