mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #23993 from overleaf/em-remove-fixed-remove-change-flag
Remove fixedRemoveChange flag from editor updates GitOrigin-RevId: bf74e1137560184c4b024a3b5c6ede5a841d3559
This commit is contained in:
@@ -306,7 +306,6 @@ class RangesTracker {
|
|||||||
const opLength = op.i.length
|
const opLength = op.i.length
|
||||||
const opEnd = op.p + opLength
|
const opEnd = op.p + opLength
|
||||||
const undoing = !!op.u
|
const undoing = !!op.u
|
||||||
const fixedRemoveChange = op.fixedRemoveChange
|
|
||||||
|
|
||||||
let alreadyMerged = false
|
let alreadyMerged = false
|
||||||
let previousChange = null
|
let previousChange = null
|
||||||
@@ -472,11 +471,7 @@ class RangesTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (change of removeChanges) {
|
for (change of removeChanges) {
|
||||||
if (fixedRemoveChange) {
|
this._removeChange(change)
|
||||||
this._removeChange(change)
|
|
||||||
} else {
|
|
||||||
this._brokenRemoveChange(change)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (change of movedChanges) {
|
for (change of movedChanges) {
|
||||||
@@ -489,7 +484,6 @@ class RangesTracker {
|
|||||||
const opLength = op.d.length
|
const opLength = op.d.length
|
||||||
const opEnd = op.p + opLength
|
const opEnd = op.p + opLength
|
||||||
const removeChanges = []
|
const removeChanges = []
|
||||||
const fixedRemoveChange = op.fixedRemoveChange
|
|
||||||
let movedChanges = []
|
let movedChanges = []
|
||||||
|
|
||||||
// We might end up modifying our delete op if it merges with existing deletes, or cancels out
|
// We might end up modifying our delete op if it merges with existing deletes, or cancels out
|
||||||
@@ -617,11 +611,7 @@ class RangesTracker {
|
|||||||
movedChanges.push(change)
|
movedChanges.push(change)
|
||||||
op.d = '' // stop it being added
|
op.d = '' // stop it being added
|
||||||
} else {
|
} else {
|
||||||
if (fixedRemoveChange) {
|
this._removeChange(change)
|
||||||
this._removeChange(change)
|
|
||||||
} else {
|
|
||||||
this._brokenRemoveChange(change)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,11 +627,7 @@ class RangesTracker {
|
|||||||
const results = this._scanAndMergeAdjacentUpdates()
|
const results = this._scanAndMergeAdjacentUpdates()
|
||||||
movedChanges = movedChanges.concat(results.movedChanges)
|
movedChanges = movedChanges.concat(results.movedChanges)
|
||||||
for (const change of results.removeChanges) {
|
for (const change of results.removeChanges) {
|
||||||
if (fixedRemoveChange) {
|
this._removeChange(change)
|
||||||
this._removeChange(change)
|
|
||||||
} else {
|
|
||||||
this._brokenRemoveChange(change)
|
|
||||||
}
|
|
||||||
movedChanges = movedChanges.filter(c => c !== change)
|
movedChanges = movedChanges.filter(c => c !== change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -683,11 +669,6 @@ class RangesTracker {
|
|||||||
this._markAsDirty(change, 'change', 'removed')
|
this._markAsDirty(change, 'change', 'removed')
|
||||||
}
|
}
|
||||||
|
|
||||||
_brokenRemoveChange(change) {
|
|
||||||
this.changes = this.changes.filter(c => c.id !== change.id)
|
|
||||||
this._markAsDirty(change, 'change', 'removed')
|
|
||||||
}
|
|
||||||
|
|
||||||
_applyOpModifications(content, opModifications) {
|
_applyOpModifications(content, opModifications) {
|
||||||
// Put in descending position order, with deleting first if at the same offset
|
// Put in descending position order, with deleting first if at the same offset
|
||||||
// (Inserting first would modify the content that the delete will delete)
|
// (Inserting first would modify the content that the delete will delete)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe('RangesTracker', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("deleting one tracked insert doesn't delete the others", function () {
|
it("deleting one tracked insert doesn't delete the others", function () {
|
||||||
this.rangesTracker.applyOp({ p: 20, d: 'two', fixedRemoveChange: true })
|
this.rangesTracker.applyOp({ p: 20, d: 'two' })
|
||||||
expect(this.rangesTracker.changes).to.deep.equal([
|
expect(this.rangesTracker.changes).to.deep.equal([
|
||||||
this.changes[0],
|
this.changes[0],
|
||||||
this.changes[2],
|
this.changes[2],
|
||||||
@@ -64,7 +64,6 @@ describe('RangesTracker', function () {
|
|||||||
this.rangesTracker.applyOp({
|
this.rangesTracker.applyOp({
|
||||||
p: 15,
|
p: 15,
|
||||||
d: '567890123456789012345',
|
d: '567890123456789012345',
|
||||||
fixedRemoveChange: true,
|
|
||||||
})
|
})
|
||||||
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([
|
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([
|
||||||
{ p: 10, d: 'one' },
|
{ p: 10, d: 'one' },
|
||||||
@@ -77,7 +76,6 @@ describe('RangesTracker', function () {
|
|||||||
this.rangesTracker.applyOp({
|
this.rangesTracker.applyOp({
|
||||||
p: 20,
|
p: 20,
|
||||||
d: '0123456789',
|
d: '0123456789',
|
||||||
fixedRemoveChange: true,
|
|
||||||
})
|
})
|
||||||
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([
|
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([
|
||||||
{ p: 10, d: 'one' },
|
{ p: 10, d: 'one' },
|
||||||
@@ -91,7 +89,6 @@ describe('RangesTracker', function () {
|
|||||||
p: 20,
|
p: 20,
|
||||||
i: 'two',
|
i: 'two',
|
||||||
u: true,
|
u: true,
|
||||||
fixedRemoveChange: true,
|
|
||||||
})
|
})
|
||||||
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([
|
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([
|
||||||
{ p: 10, d: 'one' },
|
{ p: 10, d: 'one' },
|
||||||
@@ -105,19 +102,16 @@ describe('RangesTracker', function () {
|
|||||||
p: 10,
|
p: 10,
|
||||||
i: 'one',
|
i: 'one',
|
||||||
u: true,
|
u: true,
|
||||||
fixedRemoveChange: true,
|
|
||||||
})
|
})
|
||||||
this.rangesTracker.applyOp({
|
this.rangesTracker.applyOp({
|
||||||
p: 23,
|
p: 23,
|
||||||
i: 'two',
|
i: 'two',
|
||||||
u: true,
|
u: true,
|
||||||
fixedRemoveChange: true,
|
|
||||||
})
|
})
|
||||||
this.rangesTracker.applyOp({
|
this.rangesTracker.applyOp({
|
||||||
p: 36,
|
p: 36,
|
||||||
i: 'three',
|
i: 'three',
|
||||||
u: true,
|
u: true,
|
||||||
fixedRemoveChange: true,
|
|
||||||
})
|
})
|
||||||
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([])
|
expect(this.rangesTracker.changes.map(c => c.op)).to.deep.equal([])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -696,9 +696,6 @@ export const { Doc } = (() => {
|
|||||||
var op = { p: pos, i: text };
|
var op = { p: pos, i: text };
|
||||||
if (fromUndo) {
|
if (fromUndo) {
|
||||||
op.u = true;
|
op.u = true;
|
||||||
// TODO: This flag is temporary. It is only necessary while we change
|
|
||||||
// the behaviour of tracked delete rejections in RangesTracker
|
|
||||||
op.fixedRemoveChange = true;
|
|
||||||
}
|
}
|
||||||
op = [op];
|
op = [op];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user