Change summary
internal/tui/exp/list/filterable_group.go | 23 ++++++++++++++++-------
internal/tui/exp/list/items.go | 4 +++-
2 files changed, 19 insertions(+), 8 deletions(-)
Detailed changes
@@ -264,13 +264,7 @@ func (f *filterableGroupList[T]) filterItemsInGroup(group Group[T], query string
return matchedItems
}
- // No matches, return all items without highlights
- var allItems []T
- for _, item := range group.Items {
- f.setMatchIndexes(item, make([]int, 0))
- allItems = append(allItems, item)
- }
- return allItems
+ return []T{}
}
func (f *filterableGroupList[T]) searchAllGroups(query string) []Group[T] {
@@ -319,6 +313,21 @@ func (f *filterableGroupList[T]) Filter(query string) tea.Cmd {
})
}
}
+
+ // add any matching items from other groups
+ allGroups := f.searchAllGroups(lowerQuery)
+ for _, g := range allGroups {
+ exists := false
+ for _, existing := range newGroups {
+ if existing.Section.ID() == g.Section.ID() {
+ exists = true
+ break
+ }
+ }
+ if !exists {
+ newGroups = append(newGroups, g)
+ }
+ }
} else {
// No group matches, search all groups
newGroups = f.searchAllGroups(lowerQuery)
@@ -327,18 +327,20 @@ type itemSectionModel struct {
width int
title string
inx int
+ id string
info string
}
// ID implements ItemSection.
func (m *itemSectionModel) ID() string {
- return uuid.NewString()
+ return m.id
}
func NewItemSection(title string) ItemSection {
return &itemSectionModel{
title: title,
inx: -1,
+ id: uuid.NewString(),
}
}