diff --git a/share/functions/__fish_complete_directories.fish b/share/functions/__fish_complete_directories.fish index a4db0ec22..31eaf23e1 100644 --- a/share/functions/__fish_complete_directories.fish +++ b/share/functions/__fish_complete_directories.fish @@ -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 diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 2f13b3fcf..7fabf2c45 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -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'