mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #32628 from overleaf/em-bg-history-bug
Prevent incorrect merging of ops with different hpos offsets GitOrigin-RevId: d171a93dcb29e952c7105afd81c3b29ca7e9788e
This commit is contained in:
@@ -394,6 +394,16 @@ function _concatTwoUpdates(firstUpdate, secondUpdate) {
|
||||
firstOp.p <= secondOp.p && secondOp.p <= firstOp.p + firstSize
|
||||
const combinedLengthUnderLimit = firstSize + secondSize < MAX_UPDATE_SIZE
|
||||
|
||||
// When ops come from a multi-component update, the history position offset
|
||||
// (hpos - p) may differ between ops because each component's hpos is computed
|
||||
// against a different tracked-change state. Merging ops with different
|
||||
// offsets would produce incorrect history positions, so we bail out.
|
||||
const firstHposOffset = (firstOp.hpos ?? firstOp.p) - firstOp.p
|
||||
const secondHposOffset = (secondOp.hpos ?? secondOp.p) - secondOp.p
|
||||
if (firstHposOffset !== secondHposOffset) {
|
||||
return [firstUpdate, secondUpdate]
|
||||
}
|
||||
|
||||
// Two inserts
|
||||
if (
|
||||
firstOp.i != null &&
|
||||
|
||||
Reference in New Issue
Block a user