about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_subversion63
-rw-r--r--Completion/Unix/Type/_urls4
2 files changed, 46 insertions, 21 deletions
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
index b4e47d330..9d6babed5 100644
--- a/Completion/Unix/Command/_subversion
+++ b/Completion/Unix/Command/_subversion
@@ -205,32 +205,57 @@ _svn_status() {
   (( ${(M)#${(f)_cache_svn_status[$key]}:#(#s)${~pat}*$REPLY} ))
 }
 
-(( $+functions[_svn_urls] )) ||
-_svn_urls() {
+(( $+functions[_svn_remote_paths] )) ||
+_svn_remote_paths() {
   local expl remfiles remdispf remdispd suf ret=1
 
-  if [[ -prefix *: ]] && ! _urls &&
-      zstyle -T ":completion:${curcontext}:" remote-access
-  then
-    remfiles=( ${(f)"$(svn list $IPREFIX${PREFIX%%[^./][^/]#} 2>/dev/null)"} )
-    compset -P '*/'
-    compset -S '/*' || suf=file
-    remdispf=(${remfiles:#*/})
-    remdispd=(${(M)remfiles:#*/})
-    _tags files
-    while _tags; do
-      while _next_label files expl ${suf:-directory}; do
-        [[ -n $suf ]] && compadd -S ' ' -q "$@" "$expl[@]" -d remdispf $remdispf && ret=0
-        compadd -S "${suf:+/}" -q "$@" "$expl[@]" -d remdispd ${remdispd%/} && ret=0
-      done
-      (( ret )) || return 0
+  [[ -prefix *://*/ ]] || return 1
+  zstyle -T ":completion:${curcontext}:" remote-access || return 1
+
+  remfiles=( ${(f)"$(svn list $IPREFIX${PREFIX%%[^./][^/]#} 2>/dev/null)"} )
+  (( $? == 0 )) || return 1
+
+  # you might consider trying to return early if $#remfiles is zero,
+  # but for whatever reason remfiles will always contain at least a
+  # single empty string; that case is handled correctly below.
+
+  compset -P '*/'
+  compset -S '/*' || suf=file
+  remdispf=(${remfiles:#*/})
+  remdispd=(${(M)remfiles:#*/})
+  _tags files
+  while _tags; do
+    while _next_label files expl ${suf:-directory}; do
+      # add files, unless there is a '/' immediately to the right
+      [[ -n $suf ]] &&
+      compadd -S ' ' -q "$@" "$expl[@]" -d remdispf $remdispf && ret=0
+      # add directories; use empty suffix if there is a '/' immediately to the right
+      compadd -S "${suf:+/}" -q "$@" "$expl[@]" -d remdispd ${remdispd%/} && ret=0
     done
-  else
+    (( ret )) || return 0
+  done
+
+  return 1
+}
+
+(( $+functions[_svn_urls] )) ||
+_svn_urls() {
+  local expl ret=1
+
+  # first try completing a remote path; if successful, we are all done..
+  _svn_remote_paths && return 0
+
+  # allow configuring svn repository locations using the 'urls' zstyle.
+  # always attempt completion of these because then matcher-list styles
+  # which do substring matching will work correctly.
+  _urls -S/ && ret=0
+
+  if [[ ! -prefix *://? ]] ; then
     compset -S '[^:]*'
     _wanted url-schemas expl 'URL schema' compadd -S '' - \
         file:// http:// https:// svn:// svn+ssh:// && ret=0
   fi
-  
+
   return ret
 }
 
diff --git a/Completion/Unix/Type/_urls b/Completion/Unix/Type/_urls
index 853a48553..b53f5a040 100644
--- a/Completion/Unix/Type/_urls
+++ b/Completion/Unix/Type/_urls
@@ -48,7 +48,7 @@ zstyle -a ":completion:${curcontext}:urls" urls urls
 
 if [[ $#urls -gt 1 || ( $#urls -eq 1 && ! -d $urls[1] ) ]]; then
   [[ $#urls -eq 1 && -f $urls[1] ]] && urls=( $(< $urls[1]) )
-  _wanted urls expl 'URL' compadd -a urls && return 0
+  _wanted urls expl 'URL' compadd "$@" -a urls && return 0
   urls=()
 fi
 
@@ -82,7 +82,7 @@ case "$scheme" in
     fi
   ;;
   file)
-    [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P //(127.0.0.1|localhost)
+    [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P '//(127.0.0.1|localhost)'
     [[ -prefix /// ]] && compset -P //
     if ! compset -P //; then
       _tags -C file files