Skip to content

Commit 6b986b4

Browse files
author
Yannick Scherer
committed
fix handling of whitespace-only zippers. (fixes #20)
Since 'z/edn' is 'z/edn*' + moving to the first non-whitespace node, handling whitespace-only cases is done by falling back to the latter function's behaviour and having the zipper end up on the top-level ':forms' node.
1 parent bf9604d commit 6b986b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/rewrite_clj/zip/base.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
to the first non-whitespace/non-comment child."
2323
[node]
2424
(if (= (node/tag node) :forms)
25-
(-> (edn* node)
26-
(z/down)
27-
(ws/skip-whitespace))
25+
(let [top (edn* node)]
26+
(or (-> top z/down ws/skip-whitespace)
27+
top))
2828
(recur (node/forms-node [node]))))
2929

3030
;; ## Inspection

0 commit comments

Comments
 (0)