mirror of https://github.com/spf13/cobra.git
perf(bash-v2): speed up filtering menu-complete descriptions (#1692)
Similarly as fb8031162c
(+ the empty entry
fix) did for the "regular", non-menu completion cases.
This commit is contained in:
parent
fb8031162c
commit
9e88759b19
|
@ -156,11 +156,11 @@ __%[1]s_handle_completion_types() {
|
|||
# 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}")
|
||||
|
|
Loading…
Reference in New Issue