From 332e17e8e83b98f6b8070c57bc4bd4e0aaa4e1b9 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 20 May 2018 00:38:17 -0500 Subject: [PATCH] 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. --- share/functions/__fish_complete_suffix.fish | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/share/functions/__fish_complete_suffix.fish b/share/functions/__fish_complete_suffix.fish index cde966d90..c82503aaf 100644 --- a/share/functions/__fish_complete_suffix.fish +++ b/share/functions/__fish_complete_suffix.fish @@ -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 # correct form. 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 - 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 if test $files[1] printf "%s\t$desc\n" $files 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