mirror of
https://github.com/spf13/cobra
synced 2024-11-05 05:17:12 +00:00
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
1 changed files with 2 additions and 2 deletions
|
@ -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 a new issue