mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Fix __fish_complete_suffix for arguments starting with './'
The previous completion generation was broken for several reasons: * ./foo would break detection of suffix due to the leading . being interpreted an extension marker, * ./foo would be completed as foo, which would be excluded from matching inrcomplete.cpp
This commit is contained in:
parent
376a4eca58
commit
4962244161
1 changed files with 15 additions and 3 deletions
|
@ -33,10 +33,22 @@ function __fish_complete_suffix -d "Complete using files"
|
|||
|
||||
end
|
||||
|
||||
# Perform the completion
|
||||
# Strip leading ./ as it confuses the detection of base and suffix
|
||||
# It is conditionally re-added below.
|
||||
set -l base_temp (string replace -r '^\./' '' -- $comp)
|
||||
|
||||
set base (string replace -r '\.[^.]*$' '' -- $comp | string trim -c '\'"') # " make emacs syntax highlighting happy
|
||||
eval "set files $base*$suff"
|
||||
set base (string replace -r '\.[^.]*$' '' -- $base_temp | string trim -c '\'"') # " make emacs syntax highlighting happy
|
||||
# echo "base: $base" > /dev/tty
|
||||
# echo "suffix: $suff" > /dev/tty
|
||||
|
||||
# If $comp is "./ma" and the file is "main.py", we'll catch that case here,
|
||||
# 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"
|
||||
else
|
||||
eval "set files $base*$suff"
|
||||
end
|
||||
|
||||
if test $files[1]
|
||||
printf "%s\t$desc\n" $files
|
||||
|
|
Loading…
Reference in a new issue