Commit 188d4fd7 authored by Dave Hoover's avatar Dave Hoover

Extract noise to editor.hasFile; And a couple fixes

parent 41df6899
...@@ -45,7 +45,7 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update ...@@ -45,7 +45,7 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update
gatherImports(files, missingInputs, function(input, error) { gatherImports(files, missingInputs, function(input, error) {
outputField.empty(); outputField.empty();
if (input === null) { if (input === null) {
render.error(error); renderer.error(error);
} else { } else {
var optimize = queryParams.get().optimize; var optimize = queryParams.get().optimize;
compileJSON(input, optimize ? 1 : 0); compileJSON(input, optimize ? 1 : 0);
...@@ -122,7 +122,7 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update ...@@ -122,7 +122,7 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update
} }
if (missingInputs !== undefined && missingInputs.length > 0) if (missingInputs !== undefined && missingInputs.length > 0)
this.compile(missingInputs); compile(missingInputs);
else if (noFatalErrors && !hidingRHP()) else if (noFatalErrors && !hidingRHP())
renderer.contracts(data, editor.getValue()); renderer.contracts(data, editor.getValue());
} }
...@@ -171,10 +171,10 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update ...@@ -171,10 +171,10 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update
while (importHints.length > 0) { while (importHints.length > 0) {
var m = importHints.pop(); var m = importHints.pop();
if (m in files) continue; if (m in files) continue;
if (editor.getFiles().indexOf(utils.fileKey(m)) !== -1) { if (editor.hasFile(m)) {
files[m] = window.localStorage[utils.fileKey(m)]; files[m] = window.localStorage[utils.fileKey(m)];
reloop = true; reloop = true;
} else if (m.startsWith('./') && editor.getFiles().indexOf(utils.fileKey(m.slice(2))) !== -1) { } else if (m.startsWith('./') && editor.hasFile(m.slice(2))) {
files[m] = window.localStorage[utils.fileKey(m.slice(2))]; files[m] = window.localStorage[utils.fileKey(m.slice(2))];
reloop = true; reloop = true;
} else if (m in cachedRemoteFiles) { } else if (m in cachedRemoteFiles) {
......
...@@ -38,7 +38,10 @@ function Editor(loadingFromGist) { ...@@ -38,7 +38,10 @@ function Editor(loadingFromGist) {
this.resetSession = function() { this.resetSession = function() {
editor.setSession( sessions[SOL_CACHE_FILE] ); editor.setSession( sessions[SOL_CACHE_FILE] );
editor.focus(); editor.focus();
};
this.hasFile = function(name) {
return this.getFiles().indexOf(utils.fileKey(name)) !== -1
}; };
this.getFiles = function() { this.getFiles = function() {
......
...@@ -66,7 +66,7 @@ function Renderer(web3, editor, compiler, updateFiles) { ...@@ -66,7 +66,7 @@ function Renderer(web3, editor, compiler, updateFiles) {
}); });
} }
$error.click(function(ev){ $error.click(function(ev){
if (errFile != '' && errFile != editor.getCacheFile() && editor.getFiles().indexOf(utils.fileKey(errFile)) !== -1) { if (errFile != '' && errFile != editor.getCacheFile() && editor.hasFile(errFile)) {
// Switch to file // Switch to file
editor.setCacheFile(errFile); editor.setCacheFile(errFile);
updateFiles(); updateFiles();
......
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