fixes out of bounds error on filtered selection #7

This commit is contained in:
Bradley Cicenas 2017-03-09 23:09:58 +00:00
parent 96b01eb3b9
commit b2184bbc6d
2 changed files with 13 additions and 3 deletions

View File

@ -17,7 +17,14 @@ func NewGridCursor() *GridCursor {
}
func (gc *GridCursor) Len() int { return len(gc.filtered) }
func (gc *GridCursor) Selected() *Container { return gc.filtered[gc.Idx()] }
func (gc *GridCursor) Selected() *Container {
idx := gc.Idx()
if idx < gc.Len() {
return gc.filtered[idx]
}
return nil
}
// Refresh containers from source
func (gc *GridCursor) RefreshContainers() (lenChanged bool) {

View File

@ -132,7 +132,10 @@ func Display() bool {
return false
}
if expand {
ExpandView(cursor.Selected())
c := cursor.Selected()
if c != nil {
ExpandView(c)
}
return false
}
return true