Skip to content

Commit 75eb0f6

Browse files
committed
Fix path generation in sets and maps
1 parent 7c55f47 commit 75eb0f6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: src/lib/devtools/formatters/state.cljs

+11-4
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
(number? v) v
5858
:else "?"))
5959

60-
(defn seek-path-segment [coll val]
60+
(defn seek-path-segment [coll val & [seq'd-map?]]
6161
(let [* (fn [[k v]]
6262
(cond
6363
;; we need to know the paths for keywords, these are clickable
64-
(identical? k val)
64+
(and seq'd-map? (identical? k val))
6565
(present-path-segment k)
6666

6767
(identical? v val)
@@ -70,8 +70,15 @@
7070

7171
(defn build-path-segment [parent-object object]
7272
(cond
73-
(map? parent-object) (seek-path-segment (seq parent-object) object)
74-
(sequential? parent-object) (seek-path-segment (map-indexed (fn [i x] [i x]) parent-object) object)))
73+
(map? parent-object) (seek-path-segment (seq parent-object) object true)
74+
(sequential? parent-object) (seek-path-segment (map-indexed (fn [i x] [i x]) parent-object) object)
75+
(and (set? parent-object)
76+
(contains? parent-object object)
77+
(or (string? object)
78+
(keyword? object)
79+
(integer? object))) object ;; if set has the simple object, return the object instead.
80+
(and (set? parent-object) ;; in composite objects in sets, return the index in the set.
81+
(contains? parent-object object)) (seek-path-segment (map-indexed (fn [i x] [i x]) parent-object) object)))
7582

7683
;; This function checks a unique situation of looping an immediate child element `obj` of a parent element `history`
7784
;; say we have a general map {:a 2 :b {:gh 45} :c 4}

0 commit comments

Comments
 (0)