diff --git a/lib/ace/document.js b/lib/ace/document.js index 6f526227..0d21edea 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -675,6 +675,16 @@ var Document = function(text, mode) { }, this.replace = function(range, text) { + // Shortcut: Nothing to replace in this case. + if (text.length == 0 && range.isEmpty()) { + return range.start; + } else + // 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)) { + return range.end; + } + this.$remove(range); if (text) { var end = this.$insert(range.start, text);