Skip to content

Commit aeff986

Browse files
committed
Show context-specific labels for <esc> 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.
1 parent 51066b1 commit aeff986

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pkg/gui/controllers/patch_building_controller.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func (self *PatchBuildingController) GetKeybindings(opts types.KeybindingsOpts)
4646
Key: opts.GetKey(opts.Config.Universal.Return),
4747
Handler: self.Escape,
4848
Description: self.c.Tr.ExitCustomPatchBuilder,
49+
DescriptionFunc: self.EscapeDescription,
4950
DisplayOnScreen: true,
5051
},
5152
}
@@ -180,3 +181,18 @@ func (self *PatchBuildingController) Escape() error {
180181
self.c.Helpers().PatchBuilding.Escape()
181182
return nil
182183
}
184+
185+
func (self *PatchBuildingController) EscapeDescription() string {
186+
context := self.c.Contexts().CustomPatchBuilder
187+
if state := context.GetState(); state != nil {
188+
if state.SelectingRange() {
189+
return self.c.Tr.DismissRangeSelect
190+
}
191+
192+
if state.SelectingHunkEnabledByUser() {
193+
return self.c.Tr.SelectLineByLine
194+
}
195+
}
196+
197+
return self.c.Tr.ExitCustomPatchBuilder
198+
}

pkg/gui/controllers/staging_controller.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (self *StagingController) GetKeybindings(opts types.KeybindingsOpts) []*typ
7171
Key: opts.GetKey(opts.Config.Universal.Return),
7272
Handler: self.Escape,
7373
Description: self.c.Tr.ReturnToFilesPanel,
74+
DescriptionFunc: self.EscapeDescription,
7475
DisplayOnScreen: true,
7576
},
7677
{
@@ -179,6 +180,20 @@ func (self *StagingController) Escape() error {
179180
return nil
180181
}
181182

183+
func (self *StagingController) EscapeDescription() string {
184+
if state := self.context.GetState(); state != nil {
185+
if state.SelectingRange() {
186+
return self.c.Tr.DismissRangeSelect
187+
}
188+
189+
if state.SelectingHunkEnabledByUser() {
190+
return self.c.Tr.SelectLineByLine
191+
}
192+
}
193+
194+
return self.c.Tr.ReturnToFilesPanel
195+
}
196+
182197
func (self *StagingController) TogglePanel() error {
183198
if self.otherContext.GetState() != nil {
184199
self.c.Context().Push(self.otherContext, types.OnFocusOpts{})

0 commit comments

Comments
 (0)