When using setText(), replace the entire existing text of the pad,

rather than replacing all except the last letter.
pull/2649/head
Xavid 2015-05-05 14:14:25 -04:00
parent a5872f536b
commit 5e64c292a4
2 changed files with 5 additions and 5 deletions

View File

@ -290,7 +290,7 @@ Pad.prototype.setText = function setText(newText) {
var oldText = this.text();
//create the changeset
var changeset = Changeset.makeSplice(oldText, 0, oldText.length-1, newText);
var changeset = Changeset.makeSplice(oldText, 0, oldText.length, newText);
//append the changeset
this.appendRevision(changeset);

View File

@ -260,13 +260,13 @@ exports.checkRep = function (cs) {
break;
case '-':
oldPos += o.chars;
exports.assert(oldPos < oldLen, oldPos, " >= ", oldLen, " in ", cs);
exports.assert(oldPos <= oldLen, oldPos, " > ", oldLen, " in ", cs);
break;
case '+':
{
calcNewLen += o.chars;
numInserted += o.chars;
exports.assert(calcNewLen < newLen, calcNewLen, " >= ", newLen, " in ", cs);
exports.assert(calcNewLen <= newLen, calcNewLen, " > ", newLen, " in ", cs);
break;
}
}
@ -1408,8 +1408,8 @@ exports.makeSplice = function (oldFullText, spliceStart, numRemoved, newText, op
if (spliceStart >= oldLen) {
spliceStart = oldLen - 1;
}
if (numRemoved > oldFullText.length - spliceStart - 1) {
numRemoved = oldFullText.length - spliceStart - 1;
if (numRemoved > oldFullText.length - spliceStart) {
numRemoved = oldFullText.length - spliceStart;
}
var oldText = oldFullText.substring(spliceStart, spliceStart + numRemoved);
var newLen = oldLen + newText.length - oldText.length;