diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index a5a05b150..f531d1f53 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -10,34 +10,31 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin case '--fcs-skip=*' set skip_next (string split = -- $arg)[2] case --commandline # --commandline means to use our arguments instead of the commandline. - set subcommand $argv - set -e argv - break + complete -C "$argv" + return end end set -l options_with_param $argv - if not string length -q -- $subcommand - set -l cmd (commandline -cxp | string escape) (commandline -ct) - while set -q cmd[1] - set -l token $cmd[1] - set -e cmd[1] - if contains -- $token $options_with_param - set skip_next (math $skip_next + 1) + set -l cmd (commandline -cxp | string escape) (commandline -ct) + while set -q cmd[1] + set -l token $cmd[1] + set -e cmd[1] + if contains -- $token $options_with_param + set skip_next (math $skip_next + 1) + continue + end + switch $token + case '-*' '*=*' continue - end - switch $token - case '-*' '*=*' + case '*' + if test $skip_next -gt 0 + set skip_next (math $skip_next - 1) continue - case '*' - if test $skip_next -gt 0 - set skip_next (math $skip_next - 1) - continue - end - # found the start of our command - set subcommand $token $cmd - break - end + end + # found the start of our command + set subcommand $token $cmd + break end end