Skip to content

Commit 79b37e0

Browse files
SevereOverfl0wbbatsov
authored andcommitted
Extend coercion to match cider's send format
This works around the fact that cider.el sends `[]` for `false` in the case of tests. To do this, it runs `seq` against lists. This is potentially problematic for cases where you want to search no namespaces or vars, but these circumstances seem far less common. It also fixes a long-standing hidden bug where the `load?` variable was always interpreted as `true`, due to it being `[]`. Finally, it fixes the fact that `find-ns` was used in place of `find-var` in the coercion.
1 parent cdd9450 commit 79b37e0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/cider/nrepl/middleware/util/coerce.clj

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
[ns-query]
1414
(-> ns-query
1515
(update-some :exactly
16-
#(map (fn [ns-string]
17-
(if-let [ns (find-ns (symbol ns-string))]
18-
ns
19-
(throw (ex-info "Namespace not found"
20-
{::id :namespace-not-found
21-
:namespace-string ns-string}))))
22-
%))
16+
#(seq
17+
(map (fn [ns-string]
18+
(if-let [ns (find-ns (symbol ns-string))]
19+
ns
20+
(throw (ex-info "Namespace not found"
21+
{::id :namespace-not-found
22+
:namespace-string ns-string}))))
23+
%)))
2324
(update :project? some?)
24-
(update :load-project-ns? some?)
25+
(update :load-project-ns? (fn [x]
26+
(cond
27+
(= x []) false
28+
:else (some? x))))
2529
(update :has-tests? some?)
2630
(update-some :include-regexps #(map re-pattern %))
2731
(update-some :exclude-regexps #(map re-pattern %))))
@@ -30,7 +34,7 @@
3034
[var-query]
3135
(-> var-query
3236
(update :ns-query ns-query)
33-
(update-some :exactly #(map (comp find-ns symbol) %))
37+
(update-some :exactly #(seq (keep (comp find-var symbol) %)))
3438
(update :test? some?)
3539
(update :private? some?)
3640
(update-some :include-meta-key #(map keyword %))

0 commit comments

Comments
 (0)