perf(bash-v2): speed up filtering menu-complete descriptions (#1692)
Similarly as fb8031162c2ffab270774f13c6904bb04cbba5a7 (+ the empty entry
fix) did for the "regular", non-menu completion cases.
diff --git a/bash_completionsV2.go b/bash_completionsV2.go
index a06ab45..5e558a5 100644
--- a/bash_completionsV2.go
+++ b/bash_completionsV2.go
@@ -156,11 +156,11 @@
# https://github.com/spf13/cobra/issues/1508
local tab=$'\t' comp
while IFS='' read -r comp; do
+ [[ -z $comp ]] && continue
# Strip any description
comp=${comp%%%%$tab*}
# Only consider the completions that match
- comp=$(compgen -W "$comp" -- "$cur")
- if [ -n "$comp" ]; then
+ if [[ $comp == "$cur"* ]]; then
COMPREPLY+=("$comp")
fi
done < <(printf "%%s\n" "${out}")