Fix up double release event after drag

If we press mouse, drag and then release, the release event is
generated twice, since both mouse press and mouse drag events have been
saved in mousePressed map. To fix that, ensure that we only store mouse
press events in it.
This commit is contained in:
Dmitry Maluka 2022-11-03 00:14:26 +01:00
parent 34ac83b594
commit 124fa9e2e7

View file

@ -443,14 +443,15 @@ func (h *BufPane) HandleEvent(event tcell.Event) {
mod: metaToAlt(e.Modifiers()),
state: MousePress,
}
if len(h.mousePressed) > 0 {
me.state = MouseDrag
}
isDrag := len(h.mousePressed) > 0
if e.Buttons() & ^(tcell.WheelUp|tcell.WheelDown|tcell.WheelLeft|tcell.WheelRight) != tcell.ButtonNone {
h.mousePressed[me] = true
}
if isDrag {
me.state = MouseDrag
}
h.DoMouseEvent(me, e)
} else {
// Mouse event with no click - mouse was just released.