use await in openFile

pull/2276/head
yann300 3 years ago
parent 319b584114
commit 29c8378338
  1. 24
      apps/remix-ide/src/app/files/fileManager.ts

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

Loading…
Cancel
Save