fix issue with slicing content in attrMngr

This commit is contained in:
Kevin Jahns
2025-05-31 21:00:30 +02:00
parent 172b157b7c
commit d9490c43d1
2 changed files with 2 additions and 4 deletions

View File

@@ -116,6 +116,7 @@ export {
AbstractAttributionManager, AbstractAttributionManager,
iterateStructsByIdSet, iterateStructsByIdSet,
createAttributionManagerFromDiff, createAttributionManagerFromDiff,
DiffAttributionManager,
createIdSet, createIdSet,
mergeIdSets, mergeIdSets,
cloneDoc cloneDoc

View File

@@ -339,7 +339,6 @@ export class DiffAttributionManager extends ObservableV2 {
if (content.getLength() === 0 || (content instanceof ContentDeleted && (s.attrs != null || shouldRender) && !this.inserts.has(client, s.clock))) { // @todo possibly remove this.inserts.. if (content.getLength() === 0 || (content instanceof ContentDeleted && (s.attrs != null || shouldRender) && !this.inserts.has(client, s.clock))) { // @todo possibly remove this.inserts..
// Retrieved item is never more fragmented than the newer item. // Retrieved item is never more fragmented than the newer item.
const prevItem = getItem(this._prevDocStore, createID(client, s.clock)) const prevItem = getItem(this._prevDocStore, createID(client, s.clock))
const originalContentLen = content.getLength()
content = prevItem.length > 1 ? prevItem.content.copy() : prevItem.content content = prevItem.length > 1 ? prevItem.content.copy() : prevItem.content
// trim itemContent to the correct size. // trim itemContent to the correct size.
const diffStart = s.clock - prevItem.id.clock const diffStart = s.clock - prevItem.id.clock
@@ -348,9 +347,7 @@ export class DiffAttributionManager extends ObservableV2 {
} }
} }
const c = content const c = content
if (s.len < c.getLength()) {
content = c.splice(s.len) content = c.splice(s.len)
}
if (shouldRender || !deleted || s.attrs != null) { if (shouldRender || !deleted || s.attrs != null) {
contents.push(new AttributedContent(c, deleted, s.attrs, shouldRender)) contents.push(new AttributedContent(c, deleted, s.attrs, shouldRender))
} }