Permalink
Browse files

Merge pull request #17 from ninjudd/handle_empty_slash

Handle slash without anything before it
  • Loading branch information...
ninjudd committed Jan 21, 2014
2 parents e106888 + cb31512 commit 76d4bda4ace2e3a0d5c990cb7bbfd037a6add76c
Showing with 11 additions and 6 deletions.
  1. +7 −6 src/complete/core.clj
  2. +4 −0 test/complete/core_test.clj
View
@@ -95,12 +95,13 @@
(defmethod potential-completions :scoped
[prefix ns]
- (let [scope (symbol (first (.split prefix "/")))]
- (map #(str scope "/" %)
- (if-let [class (resolve-class scope)]
- (static-members class)
- (when-let [ns (or (find-ns scope) (scope (ns-aliases ns)))]
- (ns-public-vars ns))))))
+ (when-let [prefix-scope (first (.split prefix "/"))]
+ (let [scope (symbol prefix-scope)]
+ (map #(str scope "/" %)
+ (if-let [class (resolve-class scope)]
+ (static-members class)
+ (when-let [ns (or (find-ns scope) (scope (ns-aliases ns)))]
+ (ns-public-vars ns)))))))
(defmethod potential-completions :class
[prefix ns]
@@ -20,6 +20,10 @@
(is (= '("java.lang.System/out")
(completions "java.lang.System/out")))
+ (is (= () (completions "fake-ns-here/")))
+
+ (is (= () (completions "/")))
+
(is (some #{"String/valueOf"} (completions "String/")))
(is (not (some #{"String/indexOf" ".indexOf"} (completions "String/")))))

0 comments on commit 76d4bda

Please sign in to comment.