Merge pull request #2276 from ethereum/refactor_open_filemanager

use await in openFile
pull/2274/head^2
yann300 3 years ago committed by GitHub
commit 5da761a0e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      apps/remix-ide/src/app/files/fileManager.ts

@ -625,32 +625,22 @@ class FileManager extends Plugin {
this._deps.config.set('currentFile', file)
this.openedFiles[file] = file
return new Promise((resolve, reject) => {
provider.get(file, (error, content) => {
if (error) {
console.log(error)
reject(error)
} else {
if (provider.isReadOnly(file)) {
this.editor.openReadOnly(file, content)
} else {
if (provider.isReadOnly(file)) {
this.editor.openReadOnly(file, content)
} else {
this.editor.open(file, content)
}
// TODO: Only keep `this.emit` (issue#2210)
this.emit('currentFileChanged', file)
this.events.emit('currentFileChanged', file)
resolve(true)
}
// TODO: Only keep `this.emit` (issue#2210)
this.emit('currentFileChanged', file)
this.events.emit('currentFileChanged', file)
resolve(true)
}
})
})
let content = ''
try {
content = await provider.get(file)
} catch (error) {
console.log(error)
throw error
}
if (provider.isReadOnly(file)) {
this.editor.openReadOnly(file, content)
} else {
this.editor.open(file, content)
}
// TODO: Only keep `this.emit` (issue#2210)
this.emit('currentFileChanged', file)
this.events.emit('currentFileChanged', file)
return true
}
}

Loading…
Cancel
Save