mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Changeset: Add sanity checks to slicerZipperFunc()
This commit is contained in:
parent
efeb69b4ea
commit
097f2623c6
1 changed files with 11 additions and 0 deletions
|
@ -1185,6 +1185,17 @@ const slicerZipperFunc = (attOp, csOp, pool) => {
|
||||||
copyOp(csOp, opOut);
|
copyOp(csOp, opOut);
|
||||||
csOp.opcode = '';
|
csOp.opcode = '';
|
||||||
} else {
|
} else {
|
||||||
|
for (const op of [attOp, csOp]) {
|
||||||
|
assert(op.chars >= op.lines, `op has more newlines than chars: ${op.toString()}`);
|
||||||
|
}
|
||||||
|
assert(
|
||||||
|
attOp.chars < csOp.chars ? attOp.lines <= csOp.lines
|
||||||
|
: attOp.chars > csOp.chars ? attOp.lines >= csOp.lines
|
||||||
|
: attOp.lines === csOp.lines,
|
||||||
|
'line count mismatch when composing changesets A*B; ' +
|
||||||
|
`opA: ${attOp.toString()} opB: ${csOp.toString()}`);
|
||||||
|
assert(['+', '='].includes(attOp.opcode), `unexpected opcode in op: ${attOp.toString()}`);
|
||||||
|
assert(['-', '='].includes(csOp.opcode), `unexpected opcode in op: ${csOp.toString()}`);
|
||||||
opOut.opcode = {
|
opOut.opcode = {
|
||||||
'+': {
|
'+': {
|
||||||
'-': '', // The '-' cancels out (some of) the '+', leaving any remainder for the next call.
|
'-': '', // The '-' cancels out (some of) the '+', leaving any remainder for the next call.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue