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:
Ville Skyttä 2022-05-04 23:23:02 +03:00 committed by GitHub
parent fb8031162c
commit 9e88759b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}")