Explorar el Código

tweak: remove needless resorting (#1116)

Aiden Cline hace 7 meses
padre
commit
571aeaaea2
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6 2
      packages/tui/internal/components/dialog/complete.go

+ 6 - 2
packages/tui/internal/components/dialog/complete.go

@@ -67,6 +67,7 @@ func (c *completionDialogComponent) Init() tea.Cmd {
 func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
 func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
 	return func() tea.Msg {
 	return func() tea.Msg {
 		allItems := make([]completions.CompletionSuggestion, 0)
 		allItems := make([]completions.CompletionSuggestion, 0)
+		providersWithResults := 0
 
 
 		// Collect results from all providers
 		// Collect results from all providers
 		for _, provider := range c.providers {
 		for _, provider := range c.providers {
@@ -81,11 +82,14 @@ func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
 				)
 				)
 				continue
 				continue
 			}
 			}
-			allItems = append(allItems, items...)
+			if len(items) > 0 {
+				providersWithResults++
+				allItems = append(allItems, items...)
+			}
 		}
 		}
 
 
 		// If there's a query, use fuzzy ranking to sort results
 		// If there's a query, use fuzzy ranking to sort results
-		if query != "" && len(allItems) > 0 && len(c.providers) > 1 {
+		if query != "" && providersWithResults > 1 {
 			t := theme.CurrentTheme()
 			t := theme.CurrentTheme()
 			baseStyle := styles.NewStyle().Background(t.BackgroundElement())
 			baseStyle := styles.NewStyle().Background(t.BackgroundElement())
 			// Create a slice of display values for fuzzy matching
 			// Create a slice of display values for fuzzy matching