Skip to content

Commit

Permalink
Add update ep ids on letsc-select-start
Browse files Browse the repository at this point in the history
  • Loading branch information
KGOH committed Mar 6, 2024
1 parent 786530c commit 9dff56d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/ps/sc.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@
(letsc-select-start!* @letsc-select-state ep-ids body))

([select-state ep-ids body]
(let [{:as state
saved-body :body
(let [{saved-body :body
selected-ep-id :selected-ep-id}
select-state]
(mark-selected-ep-id-value
(cond
(= saved-body body)
state
(swap! letsc-select-state assoc :ep-ids ep-ids)

(contains? (into #{} (map first) ep-ids)
selected-ep-id)
Expand All @@ -88,16 +87,15 @@
(letsc-select-start-no-mark!* @letsc-select-state ep-ids body))

([select-state ep-ids body]
(let [{:as state
saved-body :body
(let [{saved-body :body
selected-ep-id :selected-ep-id}
select-state

{:keys [ep-ids selected-ep-id]}
(->>
(cond
(= saved-body body)
state
(swap! letsc-select-state assoc :ep-ids ep-ids)

(contains? (into #{} (map first) ep-ids)
selected-ep-id)
Expand All @@ -106,7 +104,7 @@
:else
(init-letsc-select! ep-ids body)))

selected-idx (some (fn [[idx[id v]]] (when (= selected-ep-id id) idx)) (map-indexed vector ep-ids))]
selected-idx (some (fn [[idx [id _]]] (when (= selected-ep-id id) idx)) (map-indexed vector ep-ids))]
[selected-idx (map second ep-ids)])))


Expand Down
7 changes: 6 additions & 1 deletion test/ps/sc_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@
(sut/undefsc-lastdef)

(t/is (undefined-sym? `x))
(t/is (undefined-sym? `i)))))
(t/is (undefined-sym? `i)))

(t/testing "starting on the same expr updates the list"
(collatz 2)
(t/is (= [5 16 [8] 4 2 1 2 1]
(sut/letsc-select-start! 'x))))))


(t/deftest undefsc-restore-test
Expand Down

0 comments on commit 9dff56d

Please sign in to comment.