diff --git a/src/app/compiler.js b/src/app/compiler.js index 29ef1efc30..1b1e48fffb 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -63,7 +63,13 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles editor.setAnnotations(sourceAnnotations); }; - function onCompilerLoaded (setVersionText) { + function onCompilerLoaded (setVersionText, version) { + setVersionText(version); + previousInput = ''; + onChange(); + } + + function onInternalCompilerLoaded (setVersionText) { if (worker === null) { var compile; var missingInputs = []; @@ -92,11 +98,9 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles } compilationFinished(result, missingInputs); }; - setVersionText(Module.cwrap('version', 'string', [])()); + onCompilerLoaded(setVersionText, Module.cwrap('version', 'string', [])()); } - previousInput = ''; - onChange(); - }; + } function compilationFinished (result, missingInputs) { var data; @@ -153,7 +157,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles return; } window.clearInterval(check); - onCompilerLoaded(setVersionText); + onInternalCompilerLoaded(setVersionText); }, 200); } @@ -166,9 +170,8 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles var data = msg.data; switch (data.cmd) { case 'versionLoaded': - setVersionText(data.data); compilerAcceptsMultipleFiles = !!data.acceptsMultipleFiles; - onCompilerLoaded(setVersionText); + onCompilerLoaded(setVersionText, data.data); break; case 'compiled': compilationFinished(data.data, data.missingInputs);