__fish_seen_subcommand_from: Fix error when there's no second token

Regression from 2bfa7db7bc

Can be triggered e.g. with `complete -C"history "`.
This commit is contained in:
Fabian Boehm 2024-08-08 21:15:32 +02:00
parent 5f9e9cbe74
commit bd5f9babd7
2 changed files with 8 additions and 1 deletions

View File

@ -6,5 +6,5 @@
function __fish_seen_subcommand_from
set -l regex (string escape --style=regex -- (commandline -pxc)[2..] | string join '|')
string match -rq -- '^'$regex'$' $argv
string match -rq -- "^$regex"'$' $argv
end

View File

@ -614,3 +614,10 @@ function __fish_describe_command
end
test (count (complete -C"wh" | string match -rv "\tcommand|^while")) -gt 0 && echo "found" || echo "fail"
# CHECK: found
set -l commands check search show
complete -c testcommand -n "not __fish_seen_subcommand_from $commands" -a 'check\t"Check the frobnicator" search\t"Search for frobs" show\t"Show all frobs"'
complete -C'testcommand '
# CHECK: check{{\t}}Check the frobnicator
# CHECK: search{{\t}}Search for frobs
# CHECK: show{{\t}}Show all frobs