check if op.lines is in sync with atext-newlines

Conflicts:
	src/static/js/Changeset.js
This commit is contained in:
webzwo0i 2014-12-14 17:51:34 +01:00
parent 251a75346d
commit 51c14d9947
1 changed files with 16 additions and 2 deletions

View File

@ -916,6 +916,8 @@ exports.applyToText = function (cs, str) {
var csIter = exports.opIterator(unpacked.ops);
var bankIter = exports.stringIterator(unpacked.charBank);
var strIter = exports.stringIterator(str);
var newlines = 0
var newlinefail = false
var assem = exports.stringAssembler();
while (csIter.hasNext()) {
var op = csIter.next();
@ -925,16 +927,24 @@ exports.applyToText = function (cs, str) {
break;
case '-':
removedLines += op.lines;
newlines = strIter.newlines()
strIter.skip(op.chars);
if(!(newlines - strIter.newlines() == op.lines)){
newlinefail = true
}
break;
case '=':
newlines = strIter.newlines()
assem.append(strIter.take(op.chars));
if(!(newlines - strIter.newlines() == op.lines)){
newlinefail = true
}
break;
}
}
exports.assert(totalNrOfLines >= removedLines,"cannot remove ", removedLines, " lines from text with ", totalNrOfLines, " lines");
assem.append(strIter.take(strIter.remaining()));
return assem.toString();
return [assem.toString(),newlinefail];
};
/**
@ -1605,8 +1615,12 @@ exports.makeAText = function (text, attribs) {
* @param pool {AttribPool} Attribute Pool to add to
*/
exports.applyToAText = function (cs, atext, pool) {
var text = exports.applyToText(cs, atext.text)
if(text[1]){
throw new Error()
}
return {
text: exports.applyToText(cs, atext.text),
text: text[0],
attribs: exports.applyToAttribution(cs, atext.attribs, pool)
};
};