about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_tilde15
1 files changed, 8 insertions, 7 deletions
diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde
index 95d342538..06500d427 100644
--- a/Completion/Base/_tilde
+++ b/Completion/Base/_tilde
@@ -9,7 +9,7 @@
 
 setopt localoptions extendedglob
 
-local d s dirs list lines
+local d s dirs list lines revlines i
 
 if [[ "$SUFFIX" = */* ]]; then
   ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
@@ -21,22 +21,23 @@ fi
 
 if [[ -prefix [-+] ]]; then
   lines=(${(f)"$(dirs -v)"})
+  integer i
   if [[ ( -prefix - && ! -o pushdminus ) ||
 	( -prefix + && -o pushdminus ) ]]; then
-    integer tot i
-    for (( i = 1, tot = $#lines-1; i <= $#lines; i++, tot-- )); do
-      lines[$i]="$tot -- ${lines[$i]##[0-9]#[	 ]#}"
+    revlines=( $lines )
+    for (( i = 1; i <= $#lines; i++ )); do
+      lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[	 ]#}"
     done
   else
-    for (( i = 1, tot = 0; i <= $#lines; i++, tot++ )); do
-      lines[$i]="$tot -- ${lines[$i]##[0-9]#[	 ]#}"
+    for (( i = 1; i <= $#lines; i++ )); do
+      lines[$i]="$((i-1)) -- ${lines[$i]##[0-9]#[	 ]#}"
     done
   fi
   list=(${lines%% *})
 
   compset -P '[-+]'
   _description d 'directory stack'
-  compadd "$d[@]" -ld lines -Q - "$list[@]" 
+  compadd "$d[@]" -V dirs -S/ -ld lines -Q - "$list[@]" 
 else
   if (( $# )); then
     d=( "$@" )