1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-07 13:42:01 +02:00

Keep side context in context stack when pushing a main context

This fixes accordion mode for the commit files panel. When entering a file, the
commit files panel should stay expanded.
This commit is contained in:
Stefan Haller 2023-03-04 14:43:20 +01:00
parent 40a29fd622
commit 723504a290
4 changed files with 7 additions and 4 deletions

View File

@ -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()

View File

@ -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

View File

@ -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 {

View File

@ -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 {