mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 02:07:24 +00:00
fix: deduplicate command suggestions (#934)
This commit is contained in:
parent
bb28b70700
commit
f04a5e50ee
1 changed files with 7 additions and 2 deletions
|
@ -96,11 +96,16 @@ func (c *CommandCompletionProvider) GetChildEntries(
|
|||
// Sort by score (best matches first)
|
||||
sort.Sort(matches)
|
||||
|
||||
// Convert matches to completion items
|
||||
// Convert matches to completion items, deduplicating by command name
|
||||
items := []dialog.CompletionItemI{}
|
||||
seen := make(map[string]bool)
|
||||
for _, match := range matches {
|
||||
if item, ok := commandMap[match.Target]; ok {
|
||||
items = append(items, item)
|
||||
// Use the command's value (name) as the deduplication key
|
||||
if !seen[item.GetValue()] {
|
||||
seen[item.GetValue()] = true
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue