mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
add newline counting for - and + op
This commit is contained in:
parent
b4d4b16b1f
commit
ac2c7e9679
1 changed files with 15 additions and 3 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue