zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: [PATCH] _java: fix completion when $CLASSPATH contains empty entries
Date: Sat, 6 Nov 2010 10:40:09 +0100	[thread overview]
Message-ID: <AANLkTinXxNM3V=DwdwG_HfmKLeqvM4tVV1xTNUMQR_E6@mail.gmail.com> (raw)

Treat them as a . instead of a / as this is what java does.
---

jure_ on #zsh noticed that zsh took very long to complete class names, turns out
he had a trailing : in his $CLASSPATH. A quick test shows that java treats these
as a ., not a /, though this does not appear to be documented anywhere.

 Completion/Unix/Type/_java_class |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Type/_java_class b/Completion/Unix/Type/_java_class
index d81669c..0201288 100644
--- a/Completion/Unix/Type/_java_class
+++ b/Completion/Unix/Type/_java_class
@@ -13,9 +13,10 @@ classpath="${${classpath[2]:-${CLASSPATH:-.}}//\\:/:}"
 : "$classpath[@]"

 for i in "${(s.:.)classpath}"; do
-  if [ -f $i ] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
+  [[ -z $i ]] && i=.
+  if [[ -f $i ]] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
     c+=( ${${${(M)$(_call_program jar_classes jar -tf
$i)##*.class}%%.class}:gs#/#.#} )
-  elif [ -d $i ]; then
+  elif [[ -d $i ]]; then
     c+=( $i/**/*.class(.:r:s/.class//:s#$i/##:gs#/#.#) )
   fi
 done
-- 
1.7.3

-- 
Mikael Magnusson


             reply	other threads:[~2010-11-06  9:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-06  9:40 Mikael Magnusson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-11-06  9:38 Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTinXxNM3V=DwdwG_HfmKLeqvM4tVV1xTNUMQR_E6@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).