on main help sign in
feat(ui): models dialog: improve group filtering by ignoring spaces
c280dd5Ayman Bagabas
internal/ui/dialog/models_list.go+4−2
@@ -167,7 +167,9 @@ func (f *ModelsList) IsSelectedLast() bool {
167
167
168// VisibleItems returns the visible items after filtering.
168// VisibleItems returns the visible items after filtering.
169func (f *ModelsList) VisibleItems() []list.Item {
169func (f *ModelsList) VisibleItems() []list.Item {
170+ query := strings.ToLower(strings.ReplaceAll(f.query, " ", ""))
171+
170− if f.query == "" {
172+ if query == "" {
171 // No filter, return all items with group headers
173 // No filter, return all items with group headers
172 items := []list.Item{}
174 items := []list.Item{}
173 for _, g := range f.groups {
175 for _, g := range f.groups {
@@ -199,7 +201,7 @@ func (f *ModelsList) VisibleItems() []list.Item {
199 names[i] = filterValue(ms)
201 names[i] = filterValue(ms)
200 }
202 }
201
203
202− matches := fuzzy.Find(f.query, names)
204+ matches := fuzzy.Find(query, names)
203 sort.SliceStable(matches, func(i, j int) bool {
205 sort.SliceStable(matches, func(i, j int) bool {
204 return matches[i].Score > matches[j].Score
206 return matches[i].Score > matches[j].Score
205 })
207 })