aboutsummaryrefslogtreecommitdiff
path: root/vendor/maunium.net/go/tview/list.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-23 00:44:08 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-23 00:44:08 +0300
commitbedb9979a9b65dad9d72dcbdb3174508d3714f36 (patch)
treebc5adfadfac2f58fbfe198aec9d93d96cd84656f /vendor/maunium.net/go/tview/list.go
parent14903e0cdcd3ba78face2cbe0ad0287da269a1ea (diff)
Update some dependencies
Diffstat (limited to 'vendor/maunium.net/go/tview/list.go')
-rw-r--r--vendor/maunium.net/go/tview/list.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/vendor/maunium.net/go/tview/list.go b/vendor/maunium.net/go/tview/list.go
index cc25262..bc5be85 100644
--- a/vendor/maunium.net/go/tview/list.go
+++ b/vendor/maunium.net/go/tview/list.go
@@ -222,8 +222,8 @@ func (l *List) Draw(screen tcell.Screen) {
// We want to keep the current selection in view. What is our offset?
var offset int
if l.showSecondaryText {
- if l.currentItem >= height/2 {
- offset = l.currentItem + 1 - (height / 2)
+ if 2*l.currentItem >= height {
+ offset = (2*l.currentItem + 2 - height) / 2
}
} else {
if l.currentItem >= height {
@@ -296,12 +296,14 @@ func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p Primit
case tcell.KeyPgUp:
l.currentItem -= 5
case tcell.KeyEnter:
- item := l.items[l.currentItem]
- if item.Selected != nil {
- item.Selected()
- }
- if l.selected != nil {
- l.selected(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)
+ if l.currentItem >= 0 && l.currentItem < len(l.items) {
+ item := l.items[l.currentItem]
+ if item.Selected != nil {
+ item.Selected()
+ }
+ if l.selected != nil {
+ l.selected(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)
+ }
}
case tcell.KeyEscape:
if l.done != nil {