Skip to content

Commit

Permalink
Add a check in apropos var-query-map
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav committed Feb 17, 2020
1 parent 7e90679 commit 902231a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/cider/nrepl/middleware/apropos.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
(:query msg)
(assoc-in [:var-query :search] (:query msg))

(not (:case-sensitive? msg))
(and (:query msg)
(not (:case-sensitive? msg)))
(update-in [:var-query :search] #(format "(?i:%s)" %))

(:docs? msg)
Expand All @@ -38,7 +39,9 @@
(update :ns (comp find-ns symbol)))))

(defn apropos [msg]
{:apropos-matches (-> msg msg->var-query-map apropos/find-symbols)})
{:apropos-matches (-> msg
msg->var-query-map
apropos/find-symbols)})

(defn handle-apropos [handler msg]
(with-safe-transport handler msg
Expand Down
7 changes: 6 additions & 1 deletion test/clj/cider/nrepl/middleware/apropos_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
:query "spelling"}
query-map (#'apropos/msg->var-query-map msg)]
(is (contains? (:var-query query-map) :ns-query))
(is (= 3 (count (-> query-map :var-query :ns-query :exclude-regexps)))))))
(is (= 3 (count (-> query-map :var-query :ns-query :exclude-regexps))))))

(testing "No :search key in the query-map if no :query in message"
(let [msg {:exclude-regexps ["^cider.nrepl" "^refactor-nrepl" "^nrepl"]}
query-map (#'apropos/msg->var-query-map msg)]
(is ((comp contains?) (:var-query query-map) :search)))))

(deftest integration-test
(testing "Apropos op, typical case"
Expand Down

0 comments on commit 902231a

Please sign in to comment.