1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Add proper double-click handling for list views

Previously a click was detected as a double-click whenever the click was on the
already selected line, regardless of how long ago the last click was (or even
when it wasn't selected by clicking at all). Now that gocui supports proper
double-click detection, we can do better.
This commit is contained in:
Stefan Haller
2025-07-11 09:48:09 +02:00
parent 12df9d2b42
commit 37197b8e9a

View File

@ -162,7 +162,6 @@ func (self *ListController) HandleRangeSelectUp() error {
} }
func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error { func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
prevSelectedLineIdx := self.context.GetList().GetSelectedLineIdx()
newSelectedLineIdx := self.context.ViewIndexToModelIndex(opts.Y) newSelectedLineIdx := self.context.ViewIndexToModelIndex(opts.Y)
alreadyFocused := self.isFocused() alreadyFocused := self.isFocused()
@ -176,7 +175,7 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
self.context.GetList().SetSelection(newSelectedLineIdx) self.context.GetList().SetSelection(newSelectedLineIdx)
if prevSelectedLineIdx == newSelectedLineIdx && alreadyFocused && self.context.GetOnClick() != nil { if opts.IsDoubleClick && alreadyFocused && self.context.GetOnClick() != nil {
return self.context.GetOnClick()() return self.context.GetOnClick()()
} }
self.context.HandleFocus(types.OnFocusOpts{}) self.context.HandleFocus(types.OnFocusOpts{})