diff --git a/completion/_autocomplete.all_matches b/completion/_autocomplete.all_matches new file mode 100644 index 00000000..b2ae6954 --- /dev/null +++ b/completion/_autocomplete.all_matches @@ -0,0 +1,23 @@ +#autoload + +[[ -v _autocomplete__partial_list || $curcontext == *history* ]] && + return 1 + +(( CURRENT > 1 && compstate[nmatches] > 1 )) || + return + +if [[ $_completer == expand ]]; then + _autocomplete.is_glob || + return +else + [[ $words[1] != cd ]] || + return + [[ -n $_comp_tags ]] || + return + [[ -z ${${=_comp_tags}[@]:#((local-|)directories|((all|globbed)-|)files)} ]] || + return +fi + +local -a expl disp=( '' ) +_description all-matches expl 'all matches' +compadd "$expl[@]" -d disp -C diff --git a/module/.autocomplete.async b/module/.autocomplete.async index 970e02ba..f4cdd23f 100644 --- a/module/.autocomplete.async +++ b/module/.autocomplete.async @@ -383,14 +383,21 @@ bindkey -s -M menuselect '^S' '^G^S' fi local -a _matches_=() - local -i header=$+_opts_[-X] footer=1 allinsert=2 + local -i header=$+_opts_[-X] footer=0 + [[ $IPREFIX$PREFIX$SUFFIX$ISUFFIX == *${compstate[unambiguous]:#?}* ]] && + (( footer += 1 )) + ( ( [[ $_completer == expand ]] && _autocomplete.is_glob ) || + [[ $words[1] != cd && + -z ${${=_comp_tags}[@]:#((local-|)directories|((all|globbed)-|)files)} ]] ) && + (( footer += 2 )) local -i lines_available=$(( - max(0, _async_max_lines - header - footer - allinsert - compstate[list_lines]) + max( 0, _async_max_lines - header - footer - compstate[list_lines] ) )) local -i ret number_of_new_matches lines_of_new_matches if [[ -v _opts_[-D] ]]; then - .autocomplete.compadd "$@"; ret=$? + .autocomplete.compadd "$@" + ret=$? [[ $funcstack[2] == _describe ]] || return ret diff --git a/module/.autocomplete.compinit b/module/.autocomplete.compinit index c01f1c69..caa0d856 100644 --- a/module/.autocomplete.compinit +++ b/module/.autocomplete.compinit @@ -127,15 +127,7 @@ EOF _autocomplete._main_complete.post() { compstate[list_max]=0 MENUSCROLL=0 - if (( CURRENT > 1 && compstate[nmatches] > 1 )) && ( - ( [[ $_completer == expand ]] && _autocomplete.is_glob ) || - [[ $words[1] != cd && - $_comp_tags == *( (|-local)directories | (|(all|globbed)-)files ) ]] - ); then - _description all-matches expl 'all matches' - compadd "$expl[@]" -C && - _comp_tags+=' all-matches' - fi + _autocomplete.all_matches _autocomplete.unambiguous }