on main help sign in
fix: fix the group search
commitfb5e0584a75a443ee7f76a52281f7e72a353e5d3 authorkujtimiihoxha <kujtimii.h@gmail.com> dateThu 11 Sep 2025, 12:21 (1 year ago) parent15fe8df
2 files changed+19−8
internal/tui/exp/list/filterable_group.go+16−7 internal/tui/exp/list/items.go+3−1
internal/tui/exp/list/filterable_group.go+16−7
@@ -264,13 +264,7 @@ func (f *filterableGroupList[T]) filterItemsInGroup(group Group[T], query string
264264 return matchedItems
265265 }
266266
267− // No matches, return all items without highlights
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
267+ return []T{}
274268}
275269
276270func (f *filterableGroupList[T]) searchAllGroups(query string) []Group[T] {
@@ -319,6 +313,21 @@ func (f *filterableGroupList[T]) Filter(query string) tea.Cmd {
319313 })
320314 }
321315 }
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+ }
322331 } else {
323332 // No group matches, search all groups
324333 newGroups = f.searchAllGroups(lowerQuery)
internal/tui/exp/list/items.go+3−1
@@ -327,18 +327,20 @@ type itemSectionModel struct {
327327 width int
328328 title string
329329 inx int
330+ id string
330331 info string
331332}
332333
333334// ID implements ItemSection.
334335func (m *itemSectionModel) ID() string {
335− return uuid.NewString()
336+ return m.id
336337}
337338
338339func NewItemSection(title string) ItemSection {
339340 return &itemSectionModel{
340341 title: title,
341342 inx: -1,
343+ id: uuid.NewString(),
342344 }
343345}
344346