Changeset: Replace output params with return values

This improves readability and reduces the chances of introducing a
bug.
This commit is contained in:
Richard Hansen 2021-10-13 17:00:50 -04:00
parent 94f5507671
commit 1955e7b263
2 changed files with 39 additions and 67 deletions

View file

@ -273,7 +273,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
let curChar = 0;
let curLineOpIter = null;
let curLineOpIterLine;
const curLineNextOp = Changeset.newOp('+');
let curLineNextOp = Changeset.newOp('+');
const unpacked = Changeset.unpack(cs);
const csIter = Changeset.opIterator(unpacked.ops);
@ -287,7 +287,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
let indexIntoLine = 0;
let done = false;
while (!done) {
curLineOpIter.next(curLineNextOp);
curLineNextOp = curLineOpIter.next();
if (indexIntoLine + curLineNextOp.chars >= curChar) {
curLineNextOp.chars -= (curChar - indexIntoLine);
done = true;
@ -307,7 +307,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
}
if (!curLineNextOp.chars) {
curLineOpIter.next(curLineNextOp);
curLineNextOp = curLineOpIter.next();
}
const charsToUse = Math.min(numChars, curLineNextOp.chars);