diff options
author | webzwo0i <webzwo0i@c3d2.de> | 2015-02-15 15:09:38 +0100 |
---|---|---|
committer | webzwo0i <webzwo0i@c3d2.de> | 2015-02-15 15:09:38 +0100 |
commit | ac2c7e96793f05485627199bc8fd28a4562803cf (patch) | |
tree | 61f38b1ae19e18292f2af47ceea5e5c91d73887e /src/static | |
parent | b4d4b16b1f86e518be1df24c4fc5e67b923f4a4f (diff) | |
download | etherpad-lite-ac2c7e96793f05485627199bc8fd28a4562803cf.zip |
add newline counting for - and + op
Diffstat (limited to 'src/static')
-rw-r--r-- | src/static/js/Changeset.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index 2f1a53bc..a91bd1d7 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -924,18 +924,30 @@ exports.applyToText = function (cs, str) { var op = csIter.next(); switch (op.opcode) { 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)); break; 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; strIter.skip(op.chars); break; case '=': - newlines = strIter.newlines() - assem.append(strIter.take(op.chars)); - if(newlines - strIter.newlines() != op.lines){ + //op is = and op.lines 0: no newlines must be in the copied string + //op is = and op.lines >0: op.lines newlines must be in the copied string + if(op.lines != strIter.peek(op.chars).split("\n").length - 1){ newlinefail = true } + newlines = strIter.newlines() + assem.append(strIter.take(op.chars)); break; } } |