| Index: Source/devtools/front_end/CodeMirrorTextEditor.js
|
| diff --git a/Source/devtools/front_end/CodeMirrorTextEditor.js b/Source/devtools/front_end/CodeMirrorTextEditor.js
|
| index 52909f9b28616ae43bc3b0103806624b9c5a1d1e..6f2732aca4b55156af49bed51b30401b4df02ffb 100644
|
| --- a/Source/devtools/front_end/CodeMirrorTextEditor.js
|
| +++ b/Source/devtools/front_end/CodeMirrorTextEditor.js
|
| @@ -135,6 +135,8 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate)
|
| this._codeMirror.setOption("maxHighlightLength", 1000);
|
| this._codeMirror.setOption("mode", null);
|
|
|
| + this._lineSeparator = "\n";
|
| +
|
| this._tokenHighlighter = new WebInspector.CodeMirrorTextEditor.TokenHighlighter(this._codeMirror);
|
| this._blockIndentController = new WebInspector.CodeMirrorTextEditor.BlockIndentController(this._codeMirror);
|
| this._fixWordMovement = new WebInspector.CodeMirrorTextEditor.FixWordMovement(this._codeMirror);
|
| @@ -1028,12 +1030,23 @@ WebInspector.CodeMirrorTextEditor.prototype = {
|
| /**
|
| * @param {string} text
|
| */
|
| + _detectLineSeparator: function(text)
|
| + {
|
| + this._lineSeparator = text.indexOf("\r\n") >= 0 ? "\r\n" : "\n";
|
| + },
|
| +
|
| + /**
|
| + * @param {string} text
|
| + */
|
| setText: function(text)
|
| {
|
| this._muteTextChangedEvent = true;
|
| + var shouldClearHistory = !this._codeMirror.getValue().length;
|
| this._codeMirror.setValue(text);
|
| this._updateEditorIndentation();
|
| - this._codeMirror.clearHistory();
|
| + if (shouldClearHistory)
|
| + this._codeMirror.clearHistory();
|
| + this._detectLineSeparator(text);
|
| delete this._muteTextChangedEvent;
|
| },
|
|
|
| @@ -1042,7 +1055,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
|
| */
|
| text: function()
|
| {
|
| - return this._codeMirror.getValue();
|
| + return this._codeMirror.getValue().replace(/\n/g, this._lineSeparator);
|
| },
|
|
|
| /**
|
|
|