Skip to content

Commit 3fb34cf

Browse files
authored
Merge pull request zyedidia#3355 from dmaluka/tab-mouse-events-fix
Fix non-working mouse events at the top line of the screen
2 parents dc62dd9 + 0a6b32d commit 3fb34cf

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

internal/action/tab.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,18 @@ func (t *TabList) HandleEvent(event tcell.Event) {
107107
mx, my := e.Position()
108108
switch e.Buttons() {
109109
case tcell.Button1:
110-
if my == t.Y && mx == 0 {
111-
t.Scroll(-4)
112-
return
113-
} else if my == t.Y && mx == t.Width-1 {
114-
t.Scroll(4)
115-
return
116-
}
117-
if len(t.List) > 1 {
118-
ind := t.LocFromVisual(buffer.Loc{mx, my})
119-
if ind != -1 {
120-
t.SetActive(ind)
121-
return
122-
}
123-
if my == 0 {
124-
return
110+
if my == t.Y && len(t.List) > 1 {
111+
if mx == 0 {
112+
t.Scroll(-4)
113+
} else if mx == t.Width-1 {
114+
t.Scroll(4)
115+
} else {
116+
ind := t.LocFromVisual(buffer.Loc{mx, my})
117+
if ind != -1 {
118+
t.SetActive(ind)
119+
}
125120
}
121+
return
126122
}
127123
case tcell.ButtonNone:
128124
if t.List[t.Active()].release {
@@ -131,12 +127,12 @@ func (t *TabList) HandleEvent(event tcell.Event) {
131127
return
132128
}
133129
case tcell.WheelUp:
134-
if my == t.Y {
130+
if my == t.Y && len(t.List) > 1 {
135131
t.Scroll(4)
136132
return
137133
}
138134
case tcell.WheelDown:
139-
if my == t.Y {
135+
if my == t.Y && len(t.List) > 1 {
140136
t.Scroll(-4)
141137
return
142138
}

0 commit comments

Comments
 (0)