diff --git a/lib/ace/document.js b/lib/ace/document.js index bb25eeb6..20250ba7 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -166,9 +166,8 @@ var Document = function(text) { position = this.$clipPosition(position); - if (this.$lines.length <= 1) { + if (this.getLength() <= 1) this.$detectNewLine(text); - } var newLines = this.$split(text); @@ -336,15 +335,13 @@ var Document = function(text) { }; this.replace = function(range, text) { - // Shortcut: Nothing to replace in this case. if (text.length == 0 && range.isEmpty()) return range.start; // Shortcut: If the text we want to insert is the same as it is already // in the document, we don't have to replace anything. - if (text == this.getTextRange(range)) { + if (text == this.getTextRange(range)) return range.end; - } this.remove(range); if (text) {