Merge pull request #35731 from overleaf/mg-historyot-delete-at-end

Fix History OT base length when a tracked delete is in the document

GitOrigin-RevId: 414349aedd498c2635bb3067388dcc7291e32ee6
This commit is contained in:
Malik Glossop
2026-09-17 11:37:22 +00:00
committed by Copybot
parent e4bbf74476
commit 7e69642c01
3 changed files with 286 additions and 1 deletions
@@ -251,8 +251,11 @@ const updateSender = EditorState.transactionExtender.of(tr => {
const trackingUserId = tr.startState.field(trackChangesUserIdState)
const trackedDeletes = trackedDeletesFromState(tr.startState)
const startDoc = tr.startState.doc
// Seed the builder with the full snapshot length (visible length plus all
// tracked deletes). Mapping the CM length through toSnapshot under-counts
// when a tracked delete sits at the end of the document.
const opBuilder = new OperationBuilder(
trackedDeletes.toSnapshot(startDoc.length)
startDoc.length + trackedDeletes.totalLength
)
if (trackingUserId == null) {