Merge pull request #2276 from ethereum/refactor_open_filemanager

use await in openFile
pull/5370/head
yann300 3 years ago committed by GitHub
commit b60b6f3956
  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._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)
console.log(error) } catch (error) {
reject(error) console.log(error)
} else { throw error
if (provider.isReadOnly(file)) { }
this.editor.openReadOnly(file, content) if (provider.isReadOnly(file)) {
} else { this.editor.openReadOnly(file, content)
if (provider.isReadOnly(file)) { } else {
this.editor.openReadOnly(file, content) this.editor.open(file, content)
} else { }
this.editor.open(file, content) // TODO: Only keep `this.emit` (issue#2210)
} this.emit('currentFileChanged', file)
// TODO: Only keep `this.emit` (issue#2210) this.events.emit('currentFileChanged', file)
this.emit('currentFileChanged', file) return true
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)
}
})
})
} }
} }

Loading…
Cancel
Save