m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 09:03:43 -05:00

Clicks with different x coordinates shouldn't be seen as a double-click

This commit is contained in:
Junegunn Choi
2023-01-03 01:21:40 +09:00
parent 3761dc0433
commit a893fc0ca2
3 changed files with 28 additions and 46 deletions

View File

@@ -72,7 +72,7 @@ type LightRenderer struct {
forceBlack bool
clearOnExit bool
prevDownTime time.Time
clickY []int
clicks [][2]int
ttyin *os.File
buffer []byte
origState *term.State
@@ -580,15 +580,15 @@ func (r *LightRenderer) mouseSequence(sz *int) Event {
if down && !drag {
now := time.Now()
if !left { // Right double click is not allowed
r.clickY = []int{}
r.clicks = [][2]int{}
} else if now.Sub(r.prevDownTime) < doubleClickDuration {
r.clickY = append(r.clickY, y)
r.clicks = append(r.clicks, [2]int{x, y})
} else {
r.clickY = []int{y}
r.clicks = [][2]int{{x, y}}
}
r.prevDownTime = now
} else {
if len(r.clickY) > 1 && r.clickY[0] == r.clickY[1] &&
if len(r.clicks) > 1 && r.clicks[0][0] == r.clicks[1][0] && r.clicks[0][1] == r.clicks[1][1] &&
time.Since(r.prevDownTime) < doubleClickDuration {
double = true
}