From 0dd334ee46137b222aa02d14ba35635e4a559286 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 8 Aug 2020 22:36:02 +0200 Subject: [PATCH] __fish_complete_suffix: replace prefix only at start --- share/functions/__fish_complete_suffix.fish | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/share/functions/__fish_complete_suffix.fish b/share/functions/__fish_complete_suffix.fish index 48ec6b48f..c2d373869 100644 --- a/share/functions/__fish_complete_suffix.fish +++ b/share/functions/__fish_complete_suffix.fish @@ -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