mirror of
https://github.com/Hilbis/Hilbish
synced 2025-03-31 18:53:22 +00:00
fix: remove duplicate binary suggestions (fixes #105)
This commit is contained in:
parent
3babf36c43
commit
738939e4c9
@ -69,6 +69,8 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) {
|
||||
}
|
||||
}
|
||||
|
||||
completions = removeDupes(completions)
|
||||
|
||||
return completions, query
|
||||
}
|
||||
|
||||
|
13
main.go
13
main.go
@ -268,3 +268,16 @@ func expandHome(path string) string {
|
||||
|
||||
return strings.Replace(defaultHistDir, "~", homedir, 1)
|
||||
}
|
||||
|
||||
func removeDupes(slice []string) []string {
|
||||
all := make(map[string]bool)
|
||||
newSlice := []string{}
|
||||
for _, item := range slice {
|
||||
if _, val := all[item]; !val {
|
||||
all[item] = true
|
||||
newSlice = append(newSlice, item)
|
||||
}
|
||||
}
|
||||
|
||||
return newSlice
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user