summaryrefslogtreecommitdiff
path: root/src/node/db/Pad.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/db/Pad.js')
-rw-r--r--src/node/db/Pad.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js
index 8978d253..eb6a3ed1 100644
--- a/src/node/db/Pad.js
+++ b/src/node/db/Pad.js
@@ -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);