From aeff98645047d555c6754ae6fb023772bb3b2e4a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 12 Aug 2025 18:38:50 +0200 Subject: [PATCH] Show context-specific labels for in staging and patch building view Dismissing a range selection is handled by the global escape handler for all list views, but not for the staging and patch building views, so we need to make the esc description dynamic for these, too. --- pkg/gui/controllers/patch_building_controller.go | 16 ++++++++++++++++ pkg/gui/controllers/staging_controller.go | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index 1f181f210..c4f8390f6 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -46,6 +46,7 @@ func (self *PatchBuildingController) GetKeybindings(opts types.KeybindingsOpts) Key: opts.GetKey(opts.Config.Universal.Return), Handler: self.Escape, Description: self.c.Tr.ExitCustomPatchBuilder, + DescriptionFunc: self.EscapeDescription, DisplayOnScreen: true, }, } @@ -180,3 +181,18 @@ func (self *PatchBuildingController) Escape() error { self.c.Helpers().PatchBuilding.Escape() return nil } + +func (self *PatchBuildingController) EscapeDescription() string { + context := self.c.Contexts().CustomPatchBuilder + if state := context.GetState(); state != nil { + if state.SelectingRange() { + return self.c.Tr.DismissRangeSelect + } + + if state.SelectingHunkEnabledByUser() { + return self.c.Tr.SelectLineByLine + } + } + + return self.c.Tr.ExitCustomPatchBuilder +} diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 4e9a9cb86..f667dd212 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -71,6 +71,7 @@ func (self *StagingController) GetKeybindings(opts types.KeybindingsOpts) []*typ Key: opts.GetKey(opts.Config.Universal.Return), Handler: self.Escape, Description: self.c.Tr.ReturnToFilesPanel, + DescriptionFunc: self.EscapeDescription, DisplayOnScreen: true, }, { @@ -179,6 +180,20 @@ func (self *StagingController) Escape() error { return nil } +func (self *StagingController) EscapeDescription() string { + if state := self.context.GetState(); state != nil { + if state.SelectingRange() { + return self.c.Tr.DismissRangeSelect + } + + if state.SelectingHunkEnabledByUser() { + return self.c.Tr.SelectLineByLine + } + } + + return self.c.Tr.ReturnToFilesPanel +} + func (self *StagingController) TogglePanel() error { if self.otherContext.GetState() != nil { self.c.Context().Push(self.otherContext, types.OnFocusOpts{})