fix: remove duplicate binary suggestions (fixes #105)

windows-fixes
TorchedSammy 2022-03-07 18:56:22 -04:00
parent 3babf36c43
commit 738939e4c9
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
2 changed files with 15 additions and 0 deletions

View File

@ -69,6 +69,8 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) {
}
}
completions = removeDupes(completions)
return completions, query
}

13
main.go
View File

@ -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
}