on main help sign in
fix: fix the group search
fb5e058kujtimiihoxha
internal/tui/exp/list/filterable_group.go+16−7
@@ -264,13 +264,7 @@ func (f *filterableGroupList[T]) filterItemsInGroup(group Group[T], query string
264 return matchedItems
264 return matchedItems
265 }
265 }
266
266
267− // No matches, return all items without highlights
267+ return []T{}
268− var allItems []T
269− for _, item := range group.Items {
270− f.setMatchIndexes(item, make([]int, 0))
271− allItems = append(allItems, item)
272− }
273− return allItems
274}
268}
275
269
276func (f *filterableGroupList[T]) searchAllGroups(query string) []Group[T] {
270func (f *filterableGroupList[T]) searchAllGroups(query string) []Group[T] {
@@ -319,6 +313,21 @@ func (f *filterableGroupList[T]) Filter(query string) tea.Cmd {
319 })
313 })
320 }
314 }
321 }
315 }
316+
317+ // add any matching items from other groups
318+ allGroups := f.searchAllGroups(lowerQuery)
319+ for _, g := range allGroups {
320+ exists := false
321+ for _, existing := range newGroups {
322+ if existing.Section.ID() == g.Section.ID() {
323+ exists = true
324+ break
325+ }
326+ }
327+ if !exists {
328+ newGroups = append(newGroups, g)
329+ }
330+ }
322 } else {
331 } else {
323 // No group matches, search all groups
332 // No group matches, search all groups
324 newGroups = f.searchAllGroups(lowerQuery)
333 newGroups = f.searchAllGroups(lowerQuery)
internal/tui/exp/list/items.go+3−1
@@ -327,18 +327,20 @@ type itemSectionModel struct {
327 width int
327 width int
328 title string
328 title string
329 inx int
329 inx int
330+ id string
330 info string
331 info string
331}
332}
332
333
333// ID implements ItemSection.
334// ID implements ItemSection.
334func (m *itemSectionModel) ID() string {
335func (m *itemSectionModel) ID() string {
335− return uuid.NewString()
336+ return m.id
336}
337}
337
338
338func NewItemSection(title string) ItemSection {
339func NewItemSection(title string) ItemSection {
339 return &itemSectionModel{
340 return &itemSectionModel{
340 title: title,
341 title: title,
341 inx: -1,
342 inx: -1,
343+ id: uuid.NewString(),
342 }
344 }
343}
345}
344
346