Clarify that some complete calls just need a command with no user-defined completion

This commit is contained in:
Johannes Altmanninger 2020-10-02 05:48:55 +02:00
parent fb57ca8791
commit 1173e8bda4
2 changed files with 3 additions and 4 deletions

View file

@ -20,7 +20,7 @@ complete -c gitk -n 'not contains -- -- (commandline -opc)' -xa -L1 -d '-L<start
complete -c gitk -n 'not contains -- -- (commandline -opc)' -xa -L. -d '-L<funcname>:<file> trace the evolution of a function name regex'
complete -c gitk -n 'not contains -- -- (commandline -opc) && string match -rq -- "^-L[^:]*": (commandline -ct)' -xa '(
set -l tok (string split -m 1 -- : (commandline -ct))
printf -- "$tok[1]:%s\n" (complete -C": $tok[2]")
printf -- "$tok[1]:%s\n" (complete -C"__fish_command_without_completions $tok[2]")
)'
complete -c gitk -f -n 'not contains -- -- (commandline -opc)' -a '(__fish_git_ranges)'
complete -c gitk -F -n 'contains -- -- (commandline -opc)'

View file

@ -51,9 +51,8 @@ function __fish_complete_suffix -d "Complete using files"
# Simple and common case: no prefix, just complete normally and filter out unwanted suffixes.
if test -z $prefix
set -l suffix (string escape --style=regex -- $suff)
# Use normal file completions. Any valid command works here as, as long as it has no
# user-defined completions. The builtin ":" should work.
set files (complete -C ": $comp" | string match -r "^.*(?:$suffix|/)\$")
# Use normal file completions.
set files (complete -C "__fish_command_without_completions $comp" | string match -r "^.*(?:$suffix|/)\$")
else
# Strip leading ./ as it confuses the detection of base and suffix
# It is conditionally re-added below.