Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cljfmt/src/cljfmt/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,17 @@

(defn- matching-form-index? [zloc [k indexes] context]
(if (= :all indexes)
(and (z/list? zloc)
(and (or (z/list? zloc)
(= (z/tag zloc) :fn))
(form-matches-key? (z/down zloc) k context))
(and (z/list? (z/up zloc))
(form-matches-key? zloc k context)
(contains? (set indexes) (dec (index-of zloc))))))

(defn- matching-form? [zloc form-indexes context]
(and (or (z/list? zloc) (z/list? (z/up zloc)))
(and (or (z/list? zloc)
(= (z/tag zloc) :fn)
(z/list? (z/up zloc)))
(some #(matching-form-index? zloc % context) form-indexes)))

(defn align-form-columns [form aligned-forms opts]
Expand Down
16 changes: 16 additions & 0 deletions cljfmt/test/cljfmt/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,22 @@
" (sequential? x)"
" :seq)"]]
(is (reformats-to? form form {:remove-blank-lines-in-forms? true}))))
(testing "Handle #() function literals"
(let [form ["(defn increase [y]"
" (let [f #(cond"
" (pos? y)"
" (inc %)"
""
" (neg? y)"
" (dec %)"
""
" :else"
" %)]"
" (f y)))"]]
(is (reformats-to?
form
form
{:remove-blank-lines-in-forms? true}))))
(testing (str ":blank-line-forms :all should only exempt the immediate"
" children of the form")
(is (reformats-to?
Expand Down
Loading