first working version that also considers holes in document updates - #263

This commit is contained in:
Kevin Jahns
2020-12-15 15:39:08 +01:00
parent 004a781a56
commit f8341220c3
5 changed files with 65 additions and 21 deletions

View File

@@ -22,6 +22,9 @@ export class GC extends AbstractStruct {
* @return {boolean}
*/
mergeWith (right) {
if (this.constructor !== right.constructor) {
return false
}
this.length += right.length
return true
}

View File

@@ -554,6 +554,7 @@ export class Item extends AbstractStruct {
*/
mergeWith (right) {
if (
this.constructor === right.constructor &&
compareIDs(right.origin, this.lastId) &&
this.right === right &&
compareIDs(this.rightOrigin, right.rightOrigin) &&
@@ -675,7 +676,7 @@ export const readItemContent = (decoder, info) => contentRefs[info & binary.BITS
* @type {Array<function(AbstractUpdateDecoder):AbstractContent>}
*/
export const contentRefs = [
() => { throw error.unexpectedCase() }, // GC is not ItemContent
() => { error.unexpectedCase() }, // GC is not ItemContent
readContentDeleted, // 1
readContentJSON, // 2
readContentBinary, // 3
@@ -684,7 +685,8 @@ export const contentRefs = [
readContentFormat, // 6
readContentType, // 7
readContentAny, // 8
readContentDoc // 9
readContentDoc, // 9
() => { error.unexpectedCase() } // 10 - Skip is not ItemContent
]
/**