Skip to content

Commit

Permalink
perf(bash-v2): speed up filtering menu-complete descriptions (#1692)
Browse files Browse the repository at this point in the history
Similarly as fb80311 (+ the empty entry
fix) did for the "regular", non-menu completion cases.
  • Loading branch information
scop committed May 4, 2022
1 parent fb80311 commit 9e88759
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bash_completionsV2.go
Expand Up @@ -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}")
Expand Down

0 comments on commit 9e88759

Please sign in to comment.