When using setText(), replace the entire existing text of the pad,
rather than replacing all except the last letter.
This commit is contained in:
parent
a5872f536b
commit
5e64c292a4
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue