Skip to content

Commit

Permalink
[c.s.ns-mappings] Allow colon inside var names
Browse files Browse the repository at this point in the history
Fixes #39.
  • Loading branch information
alexander-yakushev committed Jun 19, 2016
1 parent 159e3de commit fa23825
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compliment/sources/ns_mappings.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(defn var-symbol?
"Test if prefix resembles a var name."
[x]
(re-matches #"[^\.\/\:]*([^\/\:]+\/[^\.\/\:]*)?" x))
(re-matches #"([^\.\/\:][^\.\/]*([^\/\:]*\/[^\.\/]*)?)?" x))

(defn dash-matches?
"Tests if prefix partially matches a var name with dashes as
Expand Down
13 changes: 13 additions & 0 deletions test/compliment/sources/t_ns_mappings.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
=> (strip-tags (just ["s/capitalize"]))
(provided (ns-aliases ..some-ns..) => {'s (find-ns 'clojure.string)}))

(fact "handles vars with semicolons in them"
(def foo:bar 1)
(def foo:baz 2)

(src/candidates "foo" *ns* nil)
=> (strip-tags (contains #{"foo:bar" "foo:baz"} :gaps-ok)) ;; passes

(src/candidates "foo:" *ns* nil)
=> (strip-tags (contains #{"foo:bar" "foo:baz"} :gaps-ok)) ;; fails

(src/candidates "foo:b" *ns* nil)
=> (strip-tags (contains #{"foo:bar" "foo:baz"} :gaps-ok))) ;; fails

(fact "extra metadata can be requested from this completion source"
(binding [*extra-metadata* #{:doc :arglists}]
(doall (src/candidates "freq" *ns* nil)))
Expand Down

0 comments on commit fa23825

Please sign in to comment.