Skip to content

Commit

Permalink
mount-point fix crash on insertion before end
Browse files Browse the repository at this point in the history
  • Loading branch information
leonoel committed Jun 25, 2024
1 parent 099643a commit 84278e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/hyperfiddle/electric/impl/mount_point.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ Mounting a block generates a grow for each active item having this block's frame
^objects bj (aget buffer j)]
(aset buffer i bj)
(aset buffer j bi)
(aset bi block-slot-index j)
(aset bj block-slot-index i)))
(when-not (nil? bi)
(aset bi block-slot-index j))
(when-not (nil? bj)
(aset bj block-slot-index i))))

(defn block-index [^objects call id]
(let [^objects reader (aget call call-slot-reader)
Expand Down Expand Up @@ -542,9 +544,11 @@ Mounting a block generates a grow for each active item having this block's frame
(if-some [index (block-index call k1)]
(p/compose
(p/split-long-swap index
(block-weight (aget buffer k1))
(if-some [b (aget buffer k1)]
(block-weight b) 0)
(weight-between call k1 k2)
(block-weight (aget buffer k2)))
(if-some [b (aget buffer k2)]
(block-weight b) 0))
q) q)))))]
(d/combine diff
{:grow 0
Expand Down
8 changes: 7 additions & 1 deletion test/hyperfiddle/electric_de_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,12 @@
tap tap)
% := (range 20)
(reset! !xs (range 10))
% := (range 10))
% := (range 10)
(reset! !xs (range 1))
% := (range 1)
(reset! !xs (reverse (range 2)))
% := (reverse (range 2))

)

)

0 comments on commit 84278e3

Please sign in to comment.