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
|
# https://github.com/spf13/cobra/issues/1508
|
||||||
local tab=$'\t' comp
|
local tab=$'\t' comp
|
||||||
while IFS='' read -r comp; do
|
while IFS='' read -r comp; do
|
||||||
|
[[ -z $comp ]] && continue
|
||||||
# Strip any description
|
# Strip any description
|
||||||
comp=${comp%%%%$tab*}
|
comp=${comp%%%%$tab*}
|
||||||
# Only consider the completions that match
|
# Only consider the completions that match
|
||||||
comp=$(compgen -W "$comp" -- "$cur")
|
if [[ $comp == "$cur"* ]]; then
|
||||||
if [ -n "$comp" ]; then
|
|
||||||
COMPREPLY+=("$comp")
|
COMPREPLY+=("$comp")
|
||||||
fi
|
fi
|
||||||
done < <(printf "%%s\n" "${out}")
|
done < <(printf "%%s\n" "${out}")
|
||||||
|
|
Loading…
Reference in New Issue