Skip to content

Commit

Permalink
Add a search key check in apropos's var-query-map (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cartmanishere authored Feb 20, 2020
1 parent 7e90679 commit 02c0ed0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bugs fixed

* [#666](https://github.com/clojure-emacs/cider-nrepl/pull/666): Add a check in apropos var-query-map.

### New Features

## 0.24.0 (2020-02-14)
Expand Down
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 ((complement contains?) (:var-query query-map) :search)))))

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

0 comments on commit 02c0ed0

Please sign in to comment.