Skip to content

Commit 37197b8

Browse files
committed
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.
1 parent 12df9d2 commit 37197b8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pkg/gui/controllers/list_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ func (self *ListController) HandleRangeSelectUp() error {
162162
}
163163

164164
func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
165-
prevSelectedLineIdx := self.context.GetList().GetSelectedLineIdx()
166165
newSelectedLineIdx := self.context.ViewIndexToModelIndex(opts.Y)
167166
alreadyFocused := self.isFocused()
168167

@@ -176,7 +175,7 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
176175

177176
self.context.GetList().SetSelection(newSelectedLineIdx)
178177

179-
if prevSelectedLineIdx == newSelectedLineIdx && alreadyFocused && self.context.GetOnClick() != nil {
178+
if opts.IsDoubleClick && alreadyFocused && self.context.GetOnClick() != nil {
180179
return self.context.GetOnClick()()
181180
}
182181
self.context.HandleFocus(types.OnFocusOpts{})

0 commit comments

Comments
 (0)