1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

Allow switching between commit message and description by clicking

It is annoying to have to tab to the description first before you can set the
cursor there by clicking.
This commit is contained in:
Stefan Haller
2024-08-15 17:50:53 +02:00
parent c2e953a09f
commit 7d486cabeb
3 changed files with 49 additions and 2 deletions

View File

@ -1,6 +1,8 @@
package controllers
import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@ -47,6 +49,16 @@ func (self *CommitDescriptionController) Context() types.Context {
return self.c.Contexts().CommitDescription
}
func (self *CommitDescriptionController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
return []*gocui.ViewMouseBinding{
{
ViewName: self.Context().GetViewName(),
Key: gocui.MouseLeft,
Handler: self.onClick,
},
}
}
func (self *CommitDescriptionController) switchToCommitMessage() error {
return self.c.Context().Replace(self.c.Contexts().CommitMessage)
}
@ -63,3 +75,12 @@ func (self *CommitDescriptionController) openCommitMenu() error {
authorSuggestion := self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc()
return self.c.Helpers().Commits.OpenCommitMenu(authorSuggestion)
}
func (self *CommitDescriptionController) onClick(opts gocui.ViewMouseBindingOpts) error {
// Activate the description panel when the commit message panel is currently active
if self.c.Context().Current().GetKey() == context.COMMIT_MESSAGE_CONTEXT_KEY {
return self.c.Context().Replace(self.c.Contexts().CommitDescription)
}
return nil
}