mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-24 19:39:16 +02:00
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.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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{})
|
||||
|
Reference in New Issue
Block a user