Skip to content

Commit 28b58c2

Browse files
rekram1-nodenipuna-perera
authored andcommitted
tweak: remove needless resorting (sst#1116)
1 parent 7190da0 commit 28b58c2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/tui/internal/components/dialog/complete.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (c *completionDialogComponent) Init() tea.Cmd {
6767
func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
6868
return func() tea.Msg {
6969
allItems := make([]completions.CompletionSuggestion, 0)
70+
providersWithResults := 0
7071

7172
// Collect results from all providers
7273
for _, provider := range c.providers {
@@ -81,11 +82,14 @@ func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
8182
)
8283
continue
8384
}
84-
allItems = append(allItems, items...)
85+
if len(items) > 0 {
86+
providersWithResults++
87+
allItems = append(allItems, items...)
88+
}
8589
}
8690

8791
// If there's a query, use fuzzy ranking to sort results
88-
if query != "" && len(allItems) > 0 && len(c.providers) > 1 {
92+
if query != "" && providersWithResults > 1 {
8993
t := theme.CurrentTheme()
9094
baseStyle := styles.NewStyle().Background(t.BackgroundElement())
9195
// Create a slice of display values for fuzzy matching

0 commit comments

Comments
 (0)