1
0
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:
Stefan Haller
2025-08-12 18:38:50 +02:00
parent 51066b14b1
commit aeff986450
2 changed files with 31 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ func (self *PatchBuildingController) GetKeybindings(opts types.KeybindingsOpts)
Key: opts.GetKey(opts.Config.Universal.Return), Key: opts.GetKey(opts.Config.Universal.Return),
Handler: self.Escape, Handler: self.Escape,
Description: self.c.Tr.ExitCustomPatchBuilder, Description: self.c.Tr.ExitCustomPatchBuilder,
DescriptionFunc: self.EscapeDescription,
DisplayOnScreen: true, DisplayOnScreen: true,
}, },
} }
@@ -180,3 +181,18 @@ func (self *PatchBuildingController) Escape() error {
self.c.Helpers().PatchBuilding.Escape() self.c.Helpers().PatchBuilding.Escape()
return nil 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
}

View File

@@ -71,6 +71,7 @@ func (self *StagingController) GetKeybindings(opts types.KeybindingsOpts) []*typ
Key: opts.GetKey(opts.Config.Universal.Return), Key: opts.GetKey(opts.Config.Universal.Return),
Handler: self.Escape, Handler: self.Escape,
Description: self.c.Tr.ReturnToFilesPanel, Description: self.c.Tr.ReturnToFilesPanel,
DescriptionFunc: self.EscapeDescription,
DisplayOnScreen: true, DisplayOnScreen: true,
}, },
{ {
@@ -179,6 +180,20 @@ func (self *StagingController) Escape() error {
return nil 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 { func (self *StagingController) TogglePanel() error {
if self.otherContext.GetState() != nil { if self.otherContext.GetState() != nil {
self.c.Context().Push(self.otherContext, types.OnFocusOpts{}) self.c.Context().Push(self.otherContext, types.OnFocusOpts{})