diff --git a/lib/util/formatting.js b/lib/util/formatting.js index e1891191eed88fef0e364f0bbe6a37ccd824b252..3a1a9873ec9705c9fed7dd648676ab80accc85b1 100644 --- a/lib/util/formatting.js +++ b/lib/util/formatting.js @@ -84,7 +84,8 @@ CodeMirror.modeExtensions["css"] = { commentStart: "/*", commentEnd: "*/", wordWrapChars: [";", "\\{", "\\}"], - autoFormatLineBreaks: function (text) { + autoFormatLineBreaks: function (text, startPos, endPos) { + text = text.substring(startPos, endPos); return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2"); } }; @@ -125,7 +126,8 @@ CodeMirror.modeExtensions["javascript"] = { return nonBreakableBlocks; }, - autoFormatLineBreaks: function (text) { + autoFormatLineBreaks: function (text, startPos, endPos) { + text = text.substring(startPos, endPos); var curPos = 0; var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n])", "g"); var nonBreakableBlocks = this.getNonBreakableBlocks(text); @@ -158,7 +160,8 @@ CodeMirror.modeExtensions["xml"] = { commentEnd: "-->", wordWrapChars: [">"], - autoFormatLineBreaks: function (text) { + autoFormatLineBreaks: function (text, startPos, endPos) { + text = text.substring(startPos, endPos); var lines = text.split("\n"); var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)"); var reOpenBrackets = new RegExp("<", "g");