From 70a4fa178a7898e9f2e41077c59d5b55133b7c03 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Sat, 6 Dec 2025 11:40:00 -0500 Subject: [PATCH] fix(list): cap rendered filterable list while keeping full search set (#1492) --- internal/tui/exp/list/filterable.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/tui/exp/list/filterable.go b/internal/tui/exp/list/filterable.go index f7ded77b9370794fee68d7ea82f961aceca0edf6..8956bfa60dd36cee115cc82ef9ea2adb758219e9 100644 --- a/internal/tui/exp/list/filterable.go +++ b/internal/tui/exp/list/filterable.go @@ -245,7 +245,7 @@ func (f *filterableList[T]) Filter(query string) tea.Cmd { f.selectedItemIdx = -1 if query == "" || len(f.items) == 0 { - return f.list.SetItems(f.items) + return f.list.SetItems(f.visibleItems(f.items)) } matches := fuzzy.FindFrom(query, f) @@ -274,7 +274,7 @@ func (f *filterableList[T]) Filter(query string) tea.Cmd { func (f *filterableList[T]) SetItems(items []T) tea.Cmd { f.items = items - return f.list.SetItems(items) + return f.list.SetItems(f.visibleItems(items)) } func (f *filterableList[T]) Cursor() *tea.Cursor { @@ -317,3 +317,13 @@ func (f *filterableList[T]) String(i int) string { func (f *filterableList[T]) Len() int { return len(f.items) } + +// visibleItems returns the subset of items that should be rendered based on +// the configured resultsSize limit. The underlying source (f.items) remains +// intact so filtering still searches the full set. +func (f *filterableList[T]) visibleItems(items []T) []T { + if f.resultsSize > 0 && len(items) > f.resultsSize { + return items[:f.resultsSize] + } + return items +}