Commit 34b6f744 authored by einbinder's avatar einbinder Committed by Commit bot

DevTools: Fix visible whitespace for cm_modes

BUG=none

Review-Url: https://codereview.chromium.org/2385793003
Cr-Commit-Position: refs/heads/master@{#422928}
parent 5371a41d
...@@ -7,8 +7,7 @@ function test() ...@@ -7,8 +7,7 @@ function test()
{ {
var mimeType = "text/x-php"; var mimeType = "text/x-php";
var textEditor = InspectorTest.createTestEditor(); var textEditor = InspectorTest.createTestEditor();
InspectorTest.addSniffer(textEditor, "_mimeTypeModesLoadedForTest", onModesLoaded); textEditor.setMimeType(mimeType).then(onModesLoaded);
textEditor.setMimeType(mimeType);
function onModesLoaded() function onModesLoaded()
{ {
......
...@@ -35,10 +35,13 @@ function test() ...@@ -35,10 +35,13 @@ function test()
function testHighlightedText(next) function testHighlightedText(next)
{ {
var textEditor = InspectorTest.createTestEditor(); var textEditor = InspectorTest.createTestEditor();
textEditor.setMimeType("text/javascript"); textEditor.setMimeType("text/javascript").then(step1);
function step1()
{
textEditor.setText(text.join("\n")); textEditor.setText(text.join("\n"));
testTokenAtPosition(textEditor); testTokenAtPosition(textEditor);
next(); next();
}
}, },
]); ]);
} }
......
...@@ -485,11 +485,13 @@ WebInspector.SourcesTextEditor.prototype = { ...@@ -485,11 +485,13 @@ WebInspector.SourcesTextEditor.prototype = {
/** /**
* @override * @override
* @param {string} mimeType * @param {string} mimeType
* @return {!Promise}
*/ */
setMimeType: function(mimeType) setMimeType: function(mimeType)
{ {
this._mimeType = mimeType; this._mimeType = mimeType;
WebInspector.CodeMirrorTextEditor.prototype.setMimeType.call(this, this._applyWhitespaceMimetype(mimeType)); return WebInspector.CodeMirrorTextEditor.prototype.setMimeType.call(this, mimeType)
.then(() => this._codeMirror.setOption("mode", this._applyWhitespaceMimetype(mimeType)));
}, },
_updateWhitespace: function() _updateWhitespace: function()
......
...@@ -698,27 +698,7 @@ WebInspector.CodeMirrorTextEditor.prototype = { ...@@ -698,27 +698,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
/** /**
* @param {string} mimeType * @param {string} mimeType
*/ * @return {!Promise}
_updateCodeMirrorMode: function(mimeType)
{
this._codeMirror.setOption("mode", mimeType);
WebInspector.CodeMirrorTextEditor._loadMimeTypeModes(mimeType, innerUpdateCodeMirrorMode.bind(this));
/**
* @this WebInspector.CodeMirrorTextEditor
*/
function innerUpdateCodeMirrorMode()
{
this._mimeTypeModesLoadedForTest();
this._updateCodeMirrorMode(mimeType);
}
},
// Do not remove, this function is sniffed in tests.
_mimeTypeModesLoadedForTest: function() { },
/**
* @param {string} mimeType
*/ */
setMimeType: function(mimeType) setMimeType: function(mimeType)
{ {
...@@ -726,7 +706,7 @@ WebInspector.CodeMirrorTextEditor.prototype = { ...@@ -726,7 +706,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
this._enableLongLinesMode(); this._enableLongLinesMode();
else else
this._disableLongLinesMode(); this._disableLongLinesMode();
this._updateCodeMirrorMode(mimeType); return WebInspector.CodeMirrorTextEditor._loadMimeTypeModes(mimeType).then(() => this._codeMirror.setOption("mode", mimeType));
}, },
/** /**
...@@ -1621,9 +1601,9 @@ WebInspector.CodeMirrorTextEditor._loadedMimeModeExtensions = new Set(); ...@@ -1621,9 +1601,9 @@ WebInspector.CodeMirrorTextEditor._loadedMimeModeExtensions = new Set();
/** /**
* @param {string} mimeType * @param {string} mimeType
* @param {function()} callback * @return {!Promise}
*/ */
WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType, callback) WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType)
{ {
var installed = WebInspector.CodeMirrorTextEditor._loadedMimeModeExtensions; var installed = WebInspector.CodeMirrorTextEditor._loadedMimeModeExtensions;
...@@ -1650,8 +1630,7 @@ WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType, callba ...@@ -1650,8 +1630,7 @@ WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType, callba
var promises = []; var promises = [];
for (var extension of modesToLoad) for (var extension of modesToLoad)
promises.push(extension.instance().then(installMode.bind(null, extension))); promises.push(extension.instance().then(installMode.bind(null, extension)));
if (promises.length) return Promise.all(promises);
Promise.all(promises).then(callback);
/** /**
* @param {!Runtime.Extension} extension * @param {!Runtime.Extension} extension
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment