diff --git a/internal/tui/exp/list/filterable_group.go b/internal/tui/exp/list/filterable_group.go index 10298b92041e6a1cfb3ad1ae4a5ca9f1c38b98d5..57aa3da3b19420a5635e35419d2865ea033eb27f 100644 --- a/internal/tui/exp/list/filterable_group.go +++ b/internal/tui/exp/list/filterable_group.go @@ -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) diff --git a/internal/tui/exp/list/items.go b/internal/tui/exp/list/items.go index b55c1dd723a245aa47ffdeb6a9ffb72fd9d8e27b..9e7259dc10a61c95e970d9f1fc93b0d61d7a65a8 100644 --- a/internal/tui/exp/list/items.go +++ b/internal/tui/exp/list/items.go @@ -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(), } }