File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 5555 (and (deref? zloc)
5656 (unquote? (z/up* zloc))))
5757
58+ (defn- comment? [zloc]
59+ (some-> zloc z/node n/comment?))
60+
5861(defn- surrounding-whitespace? [zloc]
5962 (and (not (top? zloc))
6063 (clojure-whitespace? zloc)
6164 (or (and (nil? (z/left* zloc))
6265 ; ; don't convert ~ @ to ~@
63- (not (unquote-deref? (z/right* zloc))))
66+ (not (unquote-deref? (z/right* zloc)))
67+ ; ; ignore space before comments
68+ (not (comment? (z/right* zloc))))
6469 (nil? (z/skip z/right* clojure-whitespace? zloc)))))
6570
6671(defn remove-surrounding-whitespace [form]
8792(defn- space? [zloc]
8893 (= (z/tag zloc) :whitespace ))
8994
90- (defn- comment? [zloc]
91- (some-> zloc z/node n/comment?))
92-
9395(defn- line-comment? [zloc]
9496 (and (comment? zloc) (re-matches #"(?s);;([^;].*)?" (z/string zloc))))
9597
Original file line number Diff line number Diff line change 941941 " ))" ]
942942 [" (let [x 3"
943943 " y 4]"
944- " (+ (* x x) (* y y)))" ]))))
944+ " (+ (* x x) (* y y)))" ])))
945+
946+ (testing " spacing before comments left alone"
947+ (is (reformats-to?
948+ [" [ ; comment"
949+ " 1 2 3"
950+ " ]" ]
951+ [" [ ; comment"
952+ " 1 2 3]" ]))))
945953
946954(deftest test-missing-whitespace
947955 (testing " unglue inner"
You can’t perform that action at this time.
0 commit comments