summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Completion/Unix/Type/_path_files34
1 files changed, 17 insertions, 17 deletions
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index 541a883e8..bc784426c 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -190,7 +190,23 @@ eorig="$orig"
# Now let's have a closer look at the string to complete.
-if [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
+if [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then
+
+ # If there is a parameter expansion in the word from the line, we try
+ # to complete the beast by expanding the prefix and completing anything
+ # after the first slash after the parameter expansion.
+ # This fails for things like `f/$foo/b/<TAB>' where the first `f' is
+ # meant as a partial path.
+
+ linepath="${(M)pre##*\$[^/]##/}"
+ eval 'realpath=${(e)~linepath}' 2>/dev/null
+ [[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
+ pre="${pre#${linepath}}"
+ i="${#linepath//[^\\/]}"
+ orig="${orig[1,(in:i:)/][1,-2]}"
+ donepath=
+ prepaths=( '' )
+elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
# It begins with `~', so remember anything before the first slash to be able
# to report it to the completion code. Also get an expanded version of it
# (in `realpath'), so that we can generate the matches. Then remove that
@@ -241,22 +257,6 @@ if [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
orig="${orig#*/}"
donepath=
prepaths=( '' )
-elif [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then
-
- # If there is a parameter expansion in the word from the line, we try
- # to complete the beast by expanding the prefix and completing anything
- # after the first slash after the parameter expansion.
- # This fails for things like `f/$foo/b/<TAB>' where the first `f' is
- # meant as a partial path.
-
- linepath="${(M)pre##*\$[^/]##/}"
- eval 'realpath=${(e)~linepath}' 2>/dev/null
- [[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
- pre="${pre#${linepath}}"
- i="${#linepath//[^\\/]}"
- orig="${orig[1,(in:i:)/][1,-2]}"
- donepath=
- prepaths=( '' )
else
# If the string does not start with a `~' we don't remove a prefix from the
# string.