diff --git a/pkg/gui/controllers/confirmation_controller.go b/pkg/gui/controllers/confirmation_controller.go index f121bb0f1..97754655f 100644 --- a/pkg/gui/controllers/confirmation_controller.go +++ b/pkg/gui/controllers/confirmation_controller.go @@ -3,6 +3,7 @@ package controllers import ( "fmt" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -51,6 +52,22 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [ return bindings } +func (self *ConfirmationController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding { + return []*gocui.ViewMouseBinding{ + { + ViewName: self.c.Contexts().Suggestions.GetViewName(), + FocusedView: self.c.Contexts().Confirmation.GetViewName(), + Key: gocui.MouseLeft, + Handler: func(gocui.ViewMouseBindingOpts) error { + self.switchToSuggestions() + // Let it fall through to the ListController's click handler so that + // the clicked line gets selected: + return gocui.ErrKeybindingNotHandled + }, + }, + } +} + func (self *ConfirmationController) GetOnFocusLost() func(types.OnFocusLostOpts) { return func(types.OnFocusLostOpts) { self.c.Helpers().Confirmation.DeactivateConfirmationPrompt() diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 4737bdec8..d97e56289 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -1,6 +1,7 @@ package controllers import ( + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -69,6 +70,19 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) [] return bindings } +func (self *SuggestionsController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding { + return []*gocui.ViewMouseBinding{ + { + ViewName: self.c.Contexts().Confirmation.GetViewName(), + FocusedView: self.c.Contexts().Suggestions.GetViewName(), + Key: gocui.MouseLeft, + Handler: func(gocui.ViewMouseBindingOpts) error { + return self.switchToConfirmation() + }, + }, + } +} + func (self *SuggestionsController) switchToConfirmation() error { self.c.Views().Suggestions.Subtitle = "" self.c.Views().Suggestions.Highlight = false diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 2149be119..98850cf2d 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -508,11 +508,13 @@ func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error { !gocui.IsMouseScrollKey(opts.Key) { // we ignore click events on views that aren't popup panels, when a popup panel is focused. // Unless both the current view and the clicked-on view are either commit message or commit - // description, because we want to allow switching between those two views by clicking. - isCommitMessageView := func(viewName string) bool { - return viewName == "commitMessage" || viewName == "commitDescription" + // description, or a confirmation and the suggestions view, because we want to allow switching + // between those two views by clicking. + isCommitMessageOrSuggestionsView := func(viewName string) bool { + return viewName == "commitMessage" || viewName == "commitDescription" || + viewName == "confirmation" || viewName == "suggestions" } - if !isCommitMessageView(gui.currentViewName()) || !isCommitMessageView(binding.ViewName) { + if !isCommitMessageOrSuggestionsView(gui.currentViewName()) || !isCommitMessageOrSuggestionsView(binding.ViewName) { return nil } }