Merge pull request #2101 from ethereum/remixdprovider

fix async method in remixdprovider
pull/2099/head^2
bunsenstraat 3 years ago committed by GitHub
commit eba79f2d5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/remix-ide/src/app/files/fileManager.ts
  2. 23
      apps/remix-ide/src/app/files/remixDProvider.js

@ -752,7 +752,7 @@ class FileManager extends Plugin {
if (provider) { if (provider) {
try{ try{
const content = await provider.get(currentFile) const content = await provider.get(currentFile)
this.editor.setText(content) if(content) this.editor.setText(content)
}catch(error){ }catch(error){
console.log(error) console.log(error)
} }

@ -98,20 +98,19 @@ module.exports = class RemixDProvider extends FileProvider {
}) })
} }
get (path, cb) { async get (path, cb) {
if (!this._isReady) return cb && cb('provider not ready') if (!this._isReady) return cb && cb('provider not ready')
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
this._appManager.call('remixd', 'get', { path: unprefixedpath }) try{
.then((file) => { const file = await this._appManager.call('remixd', 'get', { path: unprefixedpath })
this.filesContent[path] = file.content this.filesContent[path] = file.content
if (file.readonly) { this._readOnlyFiles[path] = 1 } if (file.readonly) { this._readOnlyFiles[path] = 1 }
cb(null, file.content) if(cb) cb(null, file.content)
}).catch((error) => { return file.content
if (error) console.log(error) } catch(error) {
// display the last known content. if (error) console.log(error)
// TODO should perhaps better warn the user that the file is not synced. if(cb) return cb(null, this.filesContent[path])
return cb(null, this.filesContent[path]) }
})
} }
async set (path, content, cb) { async set (path, content, cb) {

Loading…
Cancel
Save