add newline counting for - and + op

This commit is contained in:
webzwo0i 2015-02-15 15:09:38 +01:00
parent b4d4b16b1f
commit ac2c7e9679

View file

@ -924,18 +924,30 @@ exports.applyToText = function (cs, str) {
var op = csIter.next(); var op = csIter.next();
switch (op.opcode) { switch (op.opcode) {
case '+': case '+':
//op is + and op.lines 0: no newlines must be in op.chars
//op is + and op.lines >0: op.chars must include op.lines newlines
if(op.lines != bankIter.peek(op.chars).split("\n").length - 1){
newlinefail = true
}
assem.append(bankIter.take(op.chars)); assem.append(bankIter.take(op.chars));
break; break;
case '-': case '-':
//op is - and op.lines 0: no newlines must be in the deleted string
//op is - and op.lines >0: op.lines newlines must be in the deleted string
if(op.lines != strIter.peek(op.chars).split("\n").length - 1){
newlinefail = true
}
removedLines += op.lines; removedLines += op.lines;
strIter.skip(op.chars); strIter.skip(op.chars);
break; break;
case '=': case '=':
newlines = strIter.newlines() //op is = and op.lines 0: no newlines must be in the copied string
assem.append(strIter.take(op.chars)); //op is = and op.lines >0: op.lines newlines must be in the copied string
if(newlines - strIter.newlines() != op.lines){ if(op.lines != strIter.peek(op.chars).split("\n").length - 1){
newlinefail = true newlinefail = true
} }
newlines = strIter.newlines()
assem.append(strIter.take(op.chars));
break; break;
} }
} }