Skip to content

Commit c763c56

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 2b69462 commit c763c56

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

pkg/gui/controllers/patch_building_controller.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (self *PatchBuildingController) GetKeybindings(opts types.KeybindingsOpts)
4545
{
4646
Key: opts.GetKey(opts.Config.Universal.Return),
4747
Handler: self.Escape,
48-
Description: self.c.Tr.ExitCustomPatchBuilder,
48+
DescriptionFunc: self.EscapeDescription,
4949
DisplayOnScreen: true,
5050
},
5151
}
@@ -180,3 +180,18 @@ func (self *PatchBuildingController) Escape() error {
180180
self.c.Helpers().PatchBuilding.Escape()
181181
return nil
182182
}
183+
184+
func (self *PatchBuildingController) EscapeDescription() string {
185+
context := self.c.Contexts().CustomPatchBuilder
186+
if state := context.GetState(); state != nil {
187+
if state.SelectingRange() {
188+
return self.c.Tr.DismissRangeSelect
189+
}
190+
191+
if state.SelectingHunkEnabledByUser() {
192+
return self.c.Tr.SelectLineByLine
193+
}
194+
}
195+
196+
return self.c.Tr.ExitCustomPatchBuilder
197+
}

pkg/gui/controllers/staging_controller.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (self *StagingController) GetKeybindings(opts types.KeybindingsOpts) []*typ
7070
{
7171
Key: opts.GetKey(opts.Config.Universal.Return),
7272
Handler: self.Escape,
73-
Description: self.c.Tr.ReturnToFilesPanel,
73+
DescriptionFunc: self.EscapeDescription,
7474
DisplayOnScreen: true,
7575
},
7676
{
@@ -179,6 +179,20 @@ func (self *StagingController) Escape() error {
179179
return nil
180180
}
181181

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

0 commit comments

Comments
 (0)