🐛 Fix set unexpected deletion on reordering

This commit is contained in:
Andrey Antukh
2025-03-19 12:42:05 +01:00
parent 4453eec687
commit 39a1d5cc89

View File

@@ -49,12 +49,20 @@
:or {collapsed-paths #{}}}] :or {collapsed-paths #{}}}]
(let [tree (-> (ctob/get-set-tree tokens-lib) (let [tree (-> (ctob/get-set-tree tokens-lib)
(ctob/walk-sets-tree-seq :skip-children-pred #(contains? collapsed-paths %))) (ctob/walk-sets-tree-seq :skip-children-pred #(contains? collapsed-paths %)))
from (nth tree from-index) from (nth tree from-index)
to (nth tree to-index) to (nth tree to-index)
before (case position before (case position
:top to :top to
:bot (nth tree (inc to-index) nil) :bot (let [v (nth tree (inc to-index) nil)]
;; if the next index is a group, we need to set it as
;; nil because if we set a path on different subpath,
;; the move algorightm will simply remove the set
(if (:group? v)
nil
v))
:center nil) :center nil)
prev-before (if (:group? from) prev-before (if (:group? from)
(->> (drop (inc from-index) tree) (->> (drop (inc from-index) tree)
(filter (fn [element] (filter (fn [element]