mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Support [*{}~$] in completions with __fish_complete_suffix
Previously, trying to complete a token with any of these expansion-related characters would cause the completion to return no results, as it would emit expanded values which weren't matched by the autocompleter.
This commit is contained in:
parent
4974ecfc32
commit
332e17e8e8
1 changed files with 15 additions and 10 deletions
|
@ -45,21 +45,26 @@ function __fish_complete_suffix -d "Complete using files"
|
||||||
# but complete.cpp will not consider it a match, so we have to output the
|
# but complete.cpp will not consider it a match, so we have to output the
|
||||||
# correct form.
|
# correct form.
|
||||||
if string match -qr '^\./' -- $comp
|
if string match -qr '^\./' -- $comp
|
||||||
eval "set files ./$base*$suff"
|
# Also do directory completion, since there might be files
|
||||||
|
# with the correct suffix in a subdirectory
|
||||||
|
eval "set files ./$base*{$suff,/}"
|
||||||
else
|
else
|
||||||
eval "set files $base*$suff"
|
# Also do directory completion, since there might be files
|
||||||
|
# with the correct suffix in a subdirectory
|
||||||
|
eval "set files $base*{$suff,/}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Another problem is that expanded paths are not matched, either.
|
||||||
|
# So an expression like $HOME/foo*.zip will expand to /home/rdahl/foo-bar.zip
|
||||||
|
# but that no longer matches the expression at the command line.
|
||||||
|
if string match -qr '[${}*~]' $comp
|
||||||
|
set -l expanded
|
||||||
|
eval "set expanded $comp"
|
||||||
|
set files (string replace -- $expanded $comp $files)
|
||||||
end
|
end
|
||||||
|
|
||||||
if test $files[1]
|
if test $files[1]
|
||||||
printf "%s\t$desc\n" $files
|
printf "%s\t$desc\n" $files
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# Also do directory completion, since there might be files
|
|
||||||
# with the correct suffix in a subdirectory
|
|
||||||
# No need to describe directories (#279)
|
|
||||||
#
|
|
||||||
|
|
||||||
__fish_complete_directories $comp ""
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue