From 96e03fcfa4ab218208810011462247ff2caf8c26 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 30 Mar 2016 15:29:28 +0200 Subject: [PATCH] Use latest chainpad without mutations --- www/common/chainpad.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/common/chainpad.js b/www/common/chainpad.js index b2a81138c..502e502ab 100644 --- a/www/common/chainpad.js +++ b/www/common/chainpad.js @@ -1443,7 +1443,13 @@ var rebase = Operation.rebase = function (oldOp, newOp) { * @param transformBy an existing operation which also has the same base. * @return toTransform *or* null if the result is a no-op. */ -var transform0 = Operation.transform0 = function (text, toTransform, transformBy) { + +var transform0 = Operation.transform0 = function (text, toTransformOrig, transformByOrig) { + // Cloning the original transformations makes this algorithm such that it + // **DOES NOT MUTATE ANYMORE** + var toTransform = Operation.clone(toTransformOrig); + var transformBy = Operation.clone(transformByOrig); + if (toTransform.offset > transformBy.offset) { if (toTransform.offset > transformBy.offset + transformBy.toRemove) { // simple rebase