diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go index 931c3347f..6b41c241a 100644 --- a/pkg/gui/controllers/helpers/patch_building_helper.go +++ b/pkg/gui/controllers/helpers/patch_building_helper.go @@ -29,7 +29,11 @@ func (self *PatchBuildingHelper) ValidateNormalWorkingTreeState() (bool, error) // takes us from the patch building panel back to the commit files panel func (self *PatchBuildingHelper) Escape() { - self.c.Context().Pop() + if parentCtx := self.c.Contexts().CustomPatchBuilder.GetParentContext(); parentCtx != nil { + self.c.Context().Push(parentCtx, types.OnFocusOpts{}) + } else { + self.c.Context().Pop() + } } // kills the custom patch and returns us back to the commit files panel if needed diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index ec6c2d7a7..f8e7d3148 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -81,6 +81,7 @@ func (self *SwitchToDiffFilesController) GetOnClickFocusedMainView() func(mainVi context.GetViewTrait().FocusPoint( context.ModelIndexToViewIndex(idx)) node = context.GetSelected() + self.c.Contexts().CustomPatchBuilder.SetParentContext(self.context) return self.c.Helpers().CommitFiles.EnterCommitFile(node, types.OnFocusOpts{ClickedWindowName: "main", ClickedViewLineIdx: line, ClickedViewRealLineIdx: line}) } }