Browse Source

Fix panic when navigating empty list

merge-requests/1/merge
Trevor Slocum 2 years ago
parent
commit
7175730374
  1. 1
      CHANGELOG
  2. 13
      list.go

1
CHANGELOG

@ -1,4 +1,5 @@
v1.4.4 (WIP)
- Fix panic when navigating empty list
- Fix resize event dimensions on Windows
- Clarify that Box does not have inner text

13
list.go

@ -514,6 +514,15 @@ func (l *List) Draw(screen tcell.Screen) {
// InputHandler returns the handler for this primitive.
func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {
return l.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {
if event.Key() == tcell.KeyEscape {
if l.done != nil {
l.done()
}
return
} else if len(l.items) == 0 {
return
}
previousItem := l.currentItem
switch key := event.Key(); key {
@ -539,10 +548,6 @@ func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p Primit
l.selected(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)
}
}
case tcell.KeyEscape:
if l.done != nil {
l.done()
}
case tcell.KeyRune:
ch := event.Rune()
if ch != ' ' {

Loading…
Cancel
Save