Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Problem with completion of array indices



On Mar 8,  1:33pm, Oliver Kiddle wrote:
} Subject: Problem with completion of array indices
}
} This is with an unpatched 3.1.6-dev-19:
} 
} cd $fpath[1<tab>
} 1  -- /usr/local/share/zsh/site-functions   10   11   12   13   14
} 
} So where are the directories corresponding to 10, 11, 12, 13 and 14. As
} far as I can tell, it isn't caused by anything in _subscript so it might
} be something in compadd.

Here's a snippet of xtrace output (I comleted after path because my fpath
is not that long):

+_subscript:31> zformat -a list  --  1:~/bin 10:/usr/X11R6/bin 11:/bin 12:/usr/bin 13:/usr/rhs/bin 14:/usr/local/bin 15:/usr/X11R6/bin 16:/bin 17:/usr/bin 18:/usr/rhs/bin 19:/usr/local/bin
+_subscript:32> disp=( -d list )
+_subscript:37> [[  == ]* ]]
+_subscript:40> compadd -V -default- -S ] -d list - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

The doc for "compadd -d" says there should be one element of the array
(`list' in this case) for each word that follows the `-'.  Clearly that's
not the case here.

Index: Completion/Base/_subscript
===================================================================
@@ -24,9 +24,12 @@
       if zstyle -T ":completion:${curcontext}:indexes" verbose; then
         list=()
         for i in "$ind[@]"; do
-          [[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
+          if [[ "$i" = ${PREFIX}*${SUFFIX} ]]; then
               list=( "$list[@]" 
 	             "${i}:$(print -D ${(P)${compstate[parameter]}[$i]})" )
+	  else
+	      list=( "$list[@]" '' )
+	  fi
         done
         zformat -a list ' -- ' "$list[@]"
 	disp=( -d list)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author