Skip to content

Commit

Permalink
Sort all maps on clojure-read view
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Jan 25, 2021
1 parent 0021794 commit c29db65
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/core/com/wsscode/pathom/viz/codemirror6.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
[helix.hooks :as hooks]
[helix.core :as h]
[helix.dom :as dom]
[com.wsscode.pathom.viz.helpers :as pvh]))
[com.wsscode.pathom.viz.helpers :as pvh]
[clojure.walk :as walk]))

(def theme
(.theme EditorView
Expand Down Expand Up @@ -89,17 +90,22 @@
:whiteSpace "nowrap"}
:ref mount!})))

(defn sorted-maps [x]
(walk/postwalk
(fn [x]
(if (map? x)
(into (sorted-map) x)
x))
x))

(h/defnc EditorReadWrap [{:keys [source]}]
(let [source' (hooks/use-memo [(hash source)]
(cond
(string? source)
source

(map? source)
(pvh/pprint-str (into (sorted-map) source))

:else
(pvh/pprint-str source)))]
(pvh/pprint-str (sorted-maps source))))]
(h/$ Editor {:source source'
:readonly true})))

Expand Down

0 comments on commit c29db65

Please sign in to comment.