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{})