about summary refs log tree commit diff
path: root/Functions/Chpwd
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Chpwd')
-rw-r--r--Functions/Chpwd/chpwd_recent_filehandler19
1 files changed, 12 insertions, 7 deletions
diff --git a/Functions/Chpwd/chpwd_recent_filehandler b/Functions/Chpwd/chpwd_recent_filehandler
index b80e7f681..688612be7 100644
--- a/Functions/Chpwd/chpwd_recent_filehandler
+++ b/Functions/Chpwd/chpwd_recent_filehandler
@@ -7,8 +7,8 @@ emulate -L zsh
 setopt extendedglob
 
 integer max
-local file
-local -a files
+local file line
+local -a files dir
 local default=${ZDOTDIR:-$HOME}/.chpwd-recent-dirs
 
 if zstyle -a ':chpwd:' recent-dirs-file files; then
@@ -33,10 +33,15 @@ else
   reply=()
   for file in $files; do
     [[ -r $file ]] || continue
-    reply+=(${(Q)${(f)"$(<$file)"}})
-    if (( max > 0 && ${#reply} >= max )); then
-      reply=(${reply[1,max]})
-      break
-    fi
+    # Strip anything after the directory from the line.
+    # At the moment there isn't anything, but we'll make this
+    # future proof.
+    for line in ${(f)"$(<$file)"}; do
+      dir=(${(z)line})
+      reply+=(${(Q)${dir[1]}})
+      if (( max > 0 && ${#reply} == max )); then
+	break 2
+      fi
+    done
   done
 fi