mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Changeset: Check .hasNext()
before calling .next()
This commit is contained in:
parent
1955e7b263
commit
44d99733c6
3 changed files with 6 additions and 4 deletions
|
@ -286,7 +286,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
|
|||
curLineOpIterLine = curLine;
|
||||
let indexIntoLine = 0;
|
||||
let done = false;
|
||||
while (!done) {
|
||||
while (!done && curLineOpIter.hasNext()) {
|
||||
curLineNextOp = curLineOpIter.next();
|
||||
if (indexIntoLine + curLineNextOp.chars >= curChar) {
|
||||
curLineNextOp.chars -= (curChar - indexIntoLine);
|
||||
|
@ -307,7 +307,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
|
|||
}
|
||||
|
||||
if (!curLineNextOp.chars) {
|
||||
curLineNextOp = curLineOpIter.next();
|
||||
curLineNextOp = curLineOpIter.hasNext() ? curLineOpIter.next() : Changeset.newOp();
|
||||
}
|
||||
|
||||
const charsToUse = Math.min(numChars, curLineNextOp.chars);
|
||||
|
|
|
@ -2072,7 +2072,9 @@ exports.inverse = (cs, lines, alines, pool) => {
|
|||
curLineNextOp.chars = 0;
|
||||
curLineOpIter = exports.opIterator(alinesGet(curLine));
|
||||
}
|
||||
if (!curLineNextOp.chars) curLineNextOp = curLineOpIter.next();
|
||||
if (!curLineNextOp.chars) {
|
||||
curLineNextOp = curLineOpIter.hasNext() ? curLineOpIter.next() : exports.newOp();
|
||||
}
|
||||
const charsToUse = Math.min(numChars, curLineNextOp.chars);
|
||||
func(charsToUse, curLineNextOp.attribs, charsToUse === curLineNextOp.chars &&
|
||||
curLineNextOp.lines > 0);
|
||||
|
|
|
@ -108,7 +108,7 @@ linestylefilter.getLineStyleFilter = (lineLength, aline, textAndClassFunc, apool
|
|||
let nextOp, nextOpClasses;
|
||||
|
||||
const goNextOp = () => {
|
||||
nextOp = attributionIter.next();
|
||||
nextOp = attributionIter.hasNext() ? attributionIter.next() : Changeset.newOp();
|
||||
nextOpClasses = (nextOp.opcode && attribsToClasses(nextOp.attribs));
|
||||
};
|
||||
goNextOp();
|
||||
|
|
Loading…
Reference in a new issue