@@ -26,6 +26,15 @@ func NewModelsList(sty *styles.Styles, groups ...ModelGroup) *ModelsList {
29+// Len returns the number of model items across all groups.
30+func (f *ModelsList) Len() int {
32+ for _, g := range f.groups {
29// SetGroups sets the model groups and updates the list items.
38// SetGroups sets the model groups and updates the list items.
30func (f *ModelsList) SetGroups(groups ...ModelGroup) {
39func (f *ModelsList) SetGroups(groups ...ModelGroup) {
31 f.groups = groups
40 f.groups = groups
@@ -81,7 +90,7 @@ func (f *ModelsList) VisibleItems() []list.Item {
81 return items
90 return items
84− filterableItems := []list.FilterableItem{}
93+ filterableItems := make([]list.FilterableItem, 0, f.Len())
85 for _, g := range f.groups {
94 for _, g := range f.groups {
86 for _, item := range g.Items {
95 for _, item := range g.Items {
87 filterableItems = append(filterableItems, item)
96 filterableItems = append(filterableItems, item)