From fc09367bd0102eb5925e2035f996c98f3078392e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=A0=95=EA=B7=A0?= Date: Tue, 16 Apr 2024 13:29:29 +0900 Subject: [PATCH] Reverse TreeChanges when Deleting in Tree --- Sources/Document/CRDT/CRDTTree.swift | 2 +- Tests/Integration/TreeIntegrationTests.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Document/CRDT/CRDTTree.swift b/Sources/Document/CRDT/CRDTTree.swift index ce24ba53..07dedeb9 100644 --- a/Sources/Document/CRDT/CRDTTree.swift +++ b/Sources/Document/CRDT/CRDTTree.swift @@ -1130,7 +1130,7 @@ class CRDTTree: CRDTGCElement { } } } - return changes + return changes.reversed() } /** diff --git a/Tests/Integration/TreeIntegrationTests.swift b/Tests/Integration/TreeIntegrationTests.swift index c144bc32..99be4abe 100644 --- a/Tests/Integration/TreeIntegrationTests.swift +++ b/Tests/Integration/TreeIntegrationTests.swift @@ -3598,8 +3598,8 @@ final class TreeIntegrationTreeChangeGeneration: XCTestCase { [TreeEditOpInfoForDebug(from: 1, to: 3, value: nil, fromPath: nil, toPath: nil), TreeEditOpInfoForDebug(from: 1, to: 1, value: [JSONTreeTextNode(value: "c")], fromPath: nil, toPath: nil)], [TreeEditOpInfoForDebug(from: 2, to: 2, value: [JSONTreeTextNode(value: "c")], fromPath: nil, toPath: nil), - TreeEditOpInfoForDebug(from: 1, to: 2, value: [], fromPath: nil, toPath: nil), - TreeEditOpInfoForDebug(from: 3, to: 4, value: [], fromPath: nil, toPath: nil)]) + TreeEditOpInfoForDebug(from: 3, to: 4, value: [], fromPath: nil, toPath: nil), + TreeEditOpInfoForDebug(from: 1, to: 2, value: [], fromPath: nil, toPath: nil)]) try await d1.update { root, _ in try (root.t as? JSONTree)?.edit(1, 3) }