Skip to content

Commit

Permalink
Make aligned formatting work again
Browse files Browse the repository at this point in the history
* Fixes #2289
  • Loading branch information
PEZ committed Aug 19, 2023
1 parent 9a5a04b commit 91718ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/cljs-lib/src/calva/fmt/formatter.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@
(merge default-fmt $)))

(defn- convert-legacy-keys [config]
(cond-> config
(:legacy/merge-indents? config)
(-> (assoc :extra-indents (:indents config))
(dissoc :indents))))
(cond-> config
(:legacy/merge-indents? config)
(-> (assoc :extra-indents (:indents config))
(dissoc :indents))))

(defn- convert-to-old-config [config]
(let [new-config (convert-legacy-keys config)]
(if (:extra-indents new-config)
(-> new-config
(assoc :indents (:extra-indents new-config))
(assoc :indents (merge cljfmt/default-indents (:extra-indents new-config))))
new-config)))

(defn- read-cljfmt
[s]
Expand All @@ -45,6 +53,7 @@
(if (or align-associative?
(:align-associative? cljfmt-options))
(pez-cljfmt/reformat-string range-text (-> cljfmt-options
convert-to-old-config
(assoc :align-associative? true)
(dissoc :remove-multiple-non-indenting-spaces?)))
(cljfmt/reformat-string range-text (-> cljfmt-options
Expand Down
3 changes: 1 addition & 2 deletions src/cljs-lib/src/pez_cljfmt/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
(cond-> (:remove-trailing-whitespace? opts true)
remove-trailing-whitespace))))


(defn reformat-string
([form-string]
(reformat-string form-string {}))
Expand All @@ -479,4 +479,3 @@
(reformat-form (cond-> options
alias-map (assoc :alias-map alias-map)))
(n/string)))))

0 comments on commit 91718ee

Please sign in to comment.