__fish_complete_suffix: replace prefix only at start

This commit is contained in:
Johannes Altmanninger 2020-08-08 22:36:02 +02:00
parent b7bd7e9916
commit 0dd334ee46

View file

@ -89,9 +89,8 @@ function __fish_complete_suffix -d "Complete using files"
set desc "\t$desc"
end
if string match -qr -- . "$prefix"
# Ideally, only replace in the beginning of the string, but we have no
# way of doing a pcre2 escape so we can use a regex replace instead
set files (string replace $prefix "" $files)
set prefix (string escape --style=regex -- $prefix)
set files (string replace -r -- "^$prefix" "" $files)
end
printf "%s$desc\n" $files
end