File tree Expand file tree Collapse file tree 2 files changed +22
-14
lines changed
Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -500,12 +500,17 @@ func (h *BufPane) HandleEvent(event tcell.Event) {
500500 // Mouse event with no click - mouse was just released.
501501 // If there were multiple mouse buttons pressed, we don't know which one
502502 // was actually released, so we assume they all were released.
503+ pressed := len (h .mousePressed ) > 0
503504 for me := range h .mousePressed {
504505 delete (h .mousePressed , me )
505506
506507 me .state = MouseRelease
507508 h .DoMouseEvent (me , e )
508509 }
510+ if ! pressed {
511+ // Propagate the mouse release in case the press wasn't for this BufPane
512+ Tabs .ResetMouse ()
513+ }
509514 }
510515 }
511516 h .Buf .MergeCursors ()
Original file line number Diff line number Diff line change @@ -166,6 +166,22 @@ func (t *TabList) SetActive(a int) {
166166 }
167167}
168168
169+ // ResetMouse resets the mouse release state after the screen was stopped
170+ // or the pane changed.
171+ // This prevents situations in which mouse releases are received at the wrong place
172+ // and the mouse state is still pressed.
173+ func (t * TabList ) ResetMouse () {
174+ for _ , tab := range t .List {
175+ tab .release = true
176+
177+ for _ , p := range tab .Panes {
178+ if bp , ok := p .(* BufPane ); ok {
179+ bp .resetMouse ()
180+ }
181+ }
182+ }
183+ }
184+
169185// Tabs is the global tab list
170186var Tabs * TabList
171187
@@ -184,20 +200,7 @@ func InitTabs(bufs []*buffer.Buffer) {
184200 }
185201 }
186202
187- screen .RestartCallback = func () {
188- // The mouse could be released after the screen was stopped, so that
189- // we couldn't catch the mouse release event and would erroneously think
190- // that it is still pressed. So need to reset the mouse release state
191- // after the screen is restarted.
192- for _ , t := range Tabs .List {
193- t .release = true
194- for _ , p := range t .Panes {
195- if bp , ok := p .(* BufPane ); ok {
196- bp .resetMouse ()
197- }
198- }
199- }
200- }
203+ screen .RestartCallback = Tabs .ResetMouse
201204}
202205
203206func MainTab () * Tab {
You can’t perform that action at this time.
0 commit comments