mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #18716 from overleaf/em-tracked-delete-undo
Fix translation of tracked deletes GitOrigin-RevId: 4124db6953cbed46eea61f62118fc8e1ddfff4a0
This commit is contained in:
@@ -346,11 +346,18 @@ const UpdateManager = {
|
||||
}
|
||||
if (isDelete(op)) {
|
||||
docLength -= op.d.length
|
||||
if (!update.meta.tc || op.u) {
|
||||
// This is either a regular delete or a tracked insert rejection.
|
||||
// It will be translated to a delete in history. Tracked deletes
|
||||
// are translated into retains and don't change the history doc
|
||||
// length.
|
||||
if (update.meta.tc) {
|
||||
// This is a tracked delete. It will be translated into a retain in
|
||||
// history, except any enclosed tracked inserts, which will be
|
||||
// translated into regular deletes.
|
||||
for (const change of op.trackedChanges ?? []) {
|
||||
if (change.type === 'insert') {
|
||||
historyDocLength -= change.length
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// This is a regular delete. It will be translated to a delete in
|
||||
// history.
|
||||
historyDocLength -= op.d.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,7 +540,11 @@ describe('UpdateManager', function () {
|
||||
op: [
|
||||
{ d: 'qux', p: 4 },
|
||||
{ i: 'bazbaz', p: 14 },
|
||||
{ d: 'bong', p: 28, u: true },
|
||||
{
|
||||
d: 'bong',
|
||||
p: 28,
|
||||
trackedChanges: [{ type: 'insert', offset: 0, length: 4 }],
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
tc: 'tracking-info',
|
||||
@@ -589,7 +593,11 @@ describe('UpdateManager', function () {
|
||||
op: [
|
||||
{ d: 'qux', p: 4 },
|
||||
{ i: 'bazbaz', p: 14 },
|
||||
{ d: 'bong', p: 28, u: true },
|
||||
{
|
||||
d: 'bong',
|
||||
p: 28,
|
||||
trackedChanges: [{ type: 'insert', offset: 0, length: 4 }],
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
pathname: this.pathname,
|
||||
@@ -647,7 +655,11 @@ describe('UpdateManager', function () {
|
||||
op: [
|
||||
{ d: 'qux', p: 4 },
|
||||
{ i: 'bazbaz', p: 14 },
|
||||
{ d: 'bong', p: 28, u: true },
|
||||
{
|
||||
d: 'bong',
|
||||
p: 28,
|
||||
trackedChanges: [{ type: 'insert', offset: 0, length: 4 }],
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
pathname: this.pathname,
|
||||
|
||||
Reference in New Issue
Block a user