Skip to content

Commit b41e224

Browse files
oskarkvbbatsov
authored andcommitted
Fix font locking for fns defined with def in cljs
1 parent c63cb2e commit b41e224

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
### Bugs fixed
1111

12+
* Fix some functions defined with `def` not being properly font locked when using dynamic font locking for ClojureScript.
1213
* [#618](https://github.com/clojure-emacs/cider-nrepl/pull/618): Fix apropos to honor exclude-regexps to filter out namespaces by regex
1314
* [#605](https://github.com/clojure-emacs/cider-nrepl/pull/605): Fix `ns-vars-with-meta` to return public vars.
1415

src/cider/nrepl/middleware/track_state.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@
4040
[sym (um/relevant-meta the-meta)]))))))))
4141

4242
(defn- cljs-meta-with-fn
43-
"Like (:meta m) but adds {:fn true} if (:fn-var m) is true."
43+
"Like (:meta m) but adds {:fn true} if (:fn-var m) is true, (:tag m) is
44+
'function, or if m does not have a :tag key."
4445
[m]
4546
(cond-> (:meta m)
46-
(:fn-var m) (assoc :fn true)))
47+
(or (:fn-var m)
48+
(= (:tag m) 'function)
49+
(not (contains? m :tag)))
50+
(assoc :fn true)))
4751

4852
;;; Namespaces
4953

test/clj/cider/nrepl/middleware/track_state_test.clj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,20 @@
121121
(deftest ns-as-map-cljs-test
122122
(let [cljs-ns {:use-macros {'sym-0 #'test-fn}
123123
:uses {'sym-1 #'ns-as-map-cljs-test}
124-
:defs {'sym-2 #'ns-as-map-cljs-test
125-
'a-fn {:fn-var true}
126-
'a-var {}}
127-
:require-macros {'sym-3 'some-namespace}
128-
:requires {'sym-4 'some-namespace}}
124+
:defs {'a-fn {:fn-var true}
125+
'b-fn {:tag 'function}
126+
'c-fn {}
127+
'a-var {:tag 'something}}
128+
:require-macros {'sym-2 'some-namespace}
129+
:requires {'sym-3 'some-namespace}}
129130
{:keys [aliases interns]} (st/ns-as-map cljs-ns)]
130-
(is (= '{sym-3 some-namespace sym-4 some-namespace} aliases))
131+
(is (= '{sym-2 some-namespace sym-3 some-namespace} aliases))
131132
(is (= '{sym-0 {:arglists ([]) :macro true}
132133
sym-1 {:arglists ([])}
133-
sym-2 {}
134134
a-var {}
135-
a-fn {:fn "true"}}
135+
a-fn {:fn "true"}
136+
b-fn {:fn "true"}
137+
c-fn {:fn "true"}}
136138
interns))))
137139

138140
(deftest calculate-used-aliases-test

0 commit comments

Comments
 (0)