mirror of https://github.com/Hilbis/Hilbish
fix: remove duplicate binary suggestions (fixes #105)
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…
Reference in New Issue