diff --git a/completions/java b/completions/java index 4e0ae9ca..73a88907 100644 --- a/completions/java +++ b/completions/java @@ -72,11 +72,14 @@ _java_classes() fi elif [ -d $i ]; then - compopt -o nospace + compopt -o nospace &>/dev/null COMPREPLY=( "${COMPREPLY[@]}" - $( compgen -d -- $i/$cur | sed -e "s|^$i/\(.*\)|\1.|" ) - $( compgen -f -X '!*.class' -- $i/$cur | sed -e "s|^$i/||" ) + $( compgen -d -- "$i/$cur" | sed -e "s|^$i/\(.*\)|\1.|" ) + $( compgen -f -X '!*.class' -- "$i/$cur" | \ + sed -e '/\$/d' -e "s|^$i/||" ) ) + [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == *.class ]] && \ + compopt +o nospace &>/dev/null # FIXME: if we have foo.class and foo/, the completion # returns "foo/"... how to give precedence to files diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp index 842501d2..e41dbccc 100644 --- a/test/lib/completions/java.exp +++ b/test/lib/completions/java.exp @@ -18,7 +18,7 @@ assert_complete_any "java -" sync_after_int -assert_complete "b bashcomp.jarred toplevel" "java " +assert_complete "b bashcomp.jarred c. toplevel" "java " sync_after_int