Skip to content

Commit ed4ba59

Browse files
committed
change comment emission to preserve whitespace formatting module
3 spaces of leading whitespace (to account for traditional Lisp indent) tweak js-comment accordingly
1 parent 8cbd495 commit ed4ba59

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/main/clojure/cljs/compiler.cljc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,13 @@
481481
docs (if jsdoc (concat docs jsdoc) docs)
482482
docs (remove nil? docs)]
483483
(letfn [(print-comment-lines [e]
484-
(doseq [next-line (string/split-lines e)]
485-
(emitln " * " (-> (string/trim next-line)
486-
(string/replace "*/" "* /")))))]
484+
(let [[x & ys] (string/split-lines e)]
485+
(emitln " * " x)
486+
(doseq [next-line ys]
487+
(emitln " * "
488+
(-> next-line
489+
(string/replace #"^ " "")
490+
(string/replace "*/" "* /"))))))]
487491
(when (seq docs)
488492
(emitln "/**")
489493
(doseq [e docs]

src/main/clojure/cljs/core.cljc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,13 +871,13 @@
871871
[comment]
872872
(let [[x & ys] (string/split comment #"\n")]
873873
(core/list 'js*
874-
(core/str
875-
"\n/**\n"
876-
(core/str " * " x "\n")
877-
(core/->> ys
878-
(map #(core/str " * " (subs % 3) "\n"))
879-
(reduce core/str ""))
880-
" */\n"))))
874+
(core/str
875+
"\n/**\n"
876+
(core/str " * " x "\n")
877+
(core/->> ys
878+
(map #(core/str " * " (string/replace % #"^ " "") "\n"))
879+
(reduce core/str ""))
880+
" */\n"))))
881881

882882
(core/defmacro true? [x]
883883
(bool-expr (core/list 'js* "~{} === true" x)))

0 commit comments

Comments
 (0)