mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-23 02:41:14 -03:00
__fish_complete_subcommand: Just complete -C for a given commandline
Fixes #10980. This would, if a commandline was given, still revert to checking the *real* commandline if it was empty. Unfortunately, in those cases, it could have found a command and tried to complete it. If a commandline is given, that is what needs to be completed. (note this means this is basically useless in completions that use it like `sudo` and could just be replaced with `complete -C"$commandline"`)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user