mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Press e in focused main view (when selection is showing) to edit that line
This commit is contained in:
parent
4ced2c0c24
commit
37ca2a2395
|
|
@ -32,12 +32,17 @@ func NewMainViewController(
|
|||
|
||||
func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
|
||||
// When a selection is shown, we surface the bindings that act on it
|
||||
// (enter to dive into staging, escape to hide the selection).
|
||||
// (enter to dive into staging, e to edit the selected line, escape to hide
|
||||
// the selection).
|
||||
selectionShown := self.context.GetView().Highlight
|
||||
|
||||
var enterDescription string
|
||||
var editDescription string
|
||||
var editTooltip string
|
||||
if selectionShown {
|
||||
enterDescription = self.c.Tr.EnterStaging
|
||||
editDescription = self.c.Tr.EditFile
|
||||
editTooltip = self.c.Tr.EditFileTooltip
|
||||
}
|
||||
|
||||
return []*types.Binding{
|
||||
|
|
@ -66,6 +71,12 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty
|
|||
Description: enterDescription,
|
||||
DisplayOnScreen: selectionShown,
|
||||
},
|
||||
{
|
||||
Keys: opts.GetKeys(opts.Config.Universal.Edit),
|
||||
Handler: self.editLine,
|
||||
Description: editDescription,
|
||||
Tooltip: editTooltip,
|
||||
},
|
||||
{
|
||||
// overriding this because we want to read all of the task's output before we start searching
|
||||
Keys: opts.GetKeys(opts.Config.Universal.StartSearch),
|
||||
|
|
@ -152,6 +163,20 @@ func (self *MainViewController) enter() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (self *MainViewController) editLine() error {
|
||||
if !self.context.GetView().Highlight {
|
||||
return nil
|
||||
}
|
||||
// Figure out the clicked file and line the same way entering staging does.
|
||||
path, lineNumber, ok := self.c.Helpers().Staging.GetFileAndLineForClickedDiffLine(
|
||||
self.context.GetViewName(), self.context.GetView().SelectedLineIdx())
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
lineNumber = self.c.Helpers().Diff.AdjustLineNumber(path, lineNumber, self.context.GetViewName())
|
||||
return self.c.Helpers().Files.EditFileAtLine(path, lineNumber)
|
||||
}
|
||||
|
||||
func (self *MainViewController) onClickInAlreadyFocusedView(opts gocui.ViewMouseBindingOpts) error {
|
||||
if self.context.GetView().Highlight && !opts.IsDoubleClick {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue