mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 15:37:59 +08:00
__fish_complete_directories: Use an empty command as the dummy
Fixes #9574
(cherry picked from commit 200095998a
)
This commit is contained in:
parent
2419f39cfd
commit
17332226e4
|
@ -12,12 +12,13 @@ function __fish_complete_directories -d "Complete directory prefixes" --argument
|
|||
set comp (commandline -ct)
|
||||
end
|
||||
|
||||
# HACK: We call into the file completions by using a non-existent command.
|
||||
# HACK: We call into the file completions by using an empty command
|
||||
# If we used e.g. `ls`, we'd run the risk of completing its options or another kind of argument.
|
||||
# But since we default to file completions, if something doesn't have another completion...
|
||||
set -l dirs (complete -C"nonexistentcommandooheehoohaahaahdingdongwallawallabingbang $comp" | string match -r '.*/$')
|
||||
# (really this should have an actual complete option)
|
||||
set -l dirs (complete -C"'' $comp" | string match -r '.*/$')
|
||||
|
||||
if set -q dirs[1]
|
||||
printf "%s\t$desc\n" $dirs
|
||||
printf "%s\n" $dirs\t"$desc"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,6 +46,10 @@ complete -c t -l fileoption -rF
|
|||
complete -C't --fileoption ' | string match test.fish
|
||||
# CHECK: test.fish
|
||||
|
||||
# See that an empty command gets files
|
||||
complete -C'"" t' | string match test.fish
|
||||
# CHECK: test.fish
|
||||
|
||||
# Make sure bare `complete` is reasonable,
|
||||
complete -p '/complete test/beta1' -d 'desc, desc' -sZ
|
||||
complete -c 'complete test beta2' -r -d 'desc \' desc2 [' -a 'foo bar'
|
||||
|
|
Loading…
Reference in New Issue
Block a user