mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 00:46:16 -04:00
Restore newline-adding to setText() if passed string does not end in '\n'.
Add a test for the ending-in-'\n' case and update tests for the other case.
This commit is contained in:
parent
d803ac128e
commit
ad137fa4c8
2 changed files with 35 additions and 5 deletions
|
@ -290,7 +290,14 @@ Pad.prototype.setText = function setText(newText) {
|
|||
var oldText = this.text();
|
||||
|
||||
//create the changeset
|
||||
var changeset = Changeset.makeSplice(oldText, 0, oldText.length, newText);
|
||||
// We want to ensure the pad still ends with a \n, but otherwise keep
|
||||
// getText() and setText() consistent.
|
||||
var changeset;
|
||||
if (newText[newText.length - 1] == '\n') {
|
||||
changeset = Changeset.makeSplice(oldText, 0, oldText.length, newText);
|
||||
} else {
|
||||
changeset = Changeset.makeSplice(oldText, 0, oldText.length-1, newText);
|
||||
}
|
||||
|
||||
//append the changeset
|
||||
this.appendRevision(changeset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue