From 66d500f08dad8ebb794dc18a8a916dff2c9243ba Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Mon, 30 Sep 2019 11:07:18 +0200 Subject: [PATCH] YEvent: consider case that item was added & removed in the same transaction --- src/utils/YEvent.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/YEvent.js b/src/utils/YEvent.js index 05429ee7..3a9d1dc7 100644 --- a/src/utils/YEvent.js +++ b/src/utils/YEvent.js @@ -56,6 +56,8 @@ export class YEvent { /** * Check if a struct is deleted by this event. * + * In contrast to change.deleted, this method also returns true if the struct was added and then deleted. + * * @param {AbstractStruct} struct * @return {boolean} */ @@ -66,6 +68,8 @@ export class YEvent { /** * Check if a struct is added by this event. * + * In contrast to change.deleted, this method also returns true if the struct was added and then deleted. + * * @param {AbstractStruct} struct * @return {boolean} */ @@ -106,7 +110,7 @@ export class YEvent { } for (let item = target._start; item !== null; item = item.right) { if (item.deleted) { - if (this.deletes(item)) { + if (this.deletes(item) && !this.adds(item)) { if (lastOp === null || lastOp.delete === undefined) { packOp() lastOp = { delete: 0 }