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()
{
var mimeType = "text/x-php";
var textEditor = InspectorTest.createTestEditor();
InspectorTest.addSniffer(textEditor, "_mimeTypeModesLoadedForTest", onModesLoaded);
textEditor.setMimeType(mimeType);
textEditor.setMimeType(mimeType).then(onModesLoaded);
function onModesLoaded()
{
......
......@@ -35,10 +35,13 @@ function test()
function testHighlightedText(next)
{
var textEditor = InspectorTest.createTestEditor();
textEditor.setMimeType("text/javascript");
textEditor.setText(text.join("\n"));
testTokenAtPosition(textEditor);
next();
textEditor.setMimeType("text/javascript").then(step1);
function step1()
{
textEditor.setText(text.join("\n"));
testTokenAtPosition(textEditor);
next();
}
},
]);
}
......
......@@ -485,11 +485,13 @@ WebInspector.SourcesTextEditor.prototype = {
/**
* @override
* @param {string} mimeType
* @return {!Promise}
*/
setMimeType: function(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()
......
......@@ -698,27 +698,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
/**
* @param {string} mimeType
*/
_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
* @return {!Promise}
*/
setMimeType: function(mimeType)
{
......@@ -726,7 +706,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
this._enableLongLinesMode();
else
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();
/**
* @param {string} mimeType
* @param {function()} callback
* @return {!Promise}
*/
WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType, callback)
WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType)
{
var installed = WebInspector.CodeMirrorTextEditor._loadedMimeModeExtensions;
......@@ -1650,8 +1630,7 @@ WebInspector.CodeMirrorTextEditor._loadMimeTypeModes = function(mimeType, callba
var promises = [];
for (var extension of modesToLoad)
promises.push(extension.instance().then(installMode.bind(null, extension)));
if (promises.length)
Promise.all(promises).then(callback);
return Promise.all(promises);
/**
* @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