From 075b5fad420ee75c8af8a95a258d75cb056ec56e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 29 Mar 2025 16:52:55 +0100 Subject: [PATCH] WIP After going straight to patch building from main view, esc goes all the way back out I *think* I like it better this way, but it needs more testing. --- pkg/gui/controllers/helpers/patch_building_helper.go | 6 +++++- pkg/gui/controllers/switch_to_diff_files_controller.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go index 21baf6d18..51318a58f 100644 --- a/pkg/gui/controllers/helpers/patch_building_helper.go +++ b/pkg/gui/controllers/helpers/patch_building_helper.go @@ -44,7 +44,11 @@ func (self *PatchBuildingHelper) ShowHunkStagingHint() { // 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 2c6d60bcf..2be299b5b 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -83,6 +83,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}) } }