mirror of https://github.com/rivo/tview.git
Fix panic with empty list
This commit is contained in:
parent
213c37c368
commit
2899c719ca
14
list.go
14
list.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue