sync editor to current saved content

pull/3094/head
yann300 6 years ago
parent f5087bfa7c
commit bc767fb496
  1. 16
      src/app/files/fileManager.js
  2. 3
      src/app/plugin/pluginAPI.js

@ -195,6 +195,22 @@ class FileManager {
}
}
}
syncEditor (path) {
var self = this
var currentFile = this._deps.config.get('currentFile')
if (path !== currentFile) return
var provider = this.fileProviderOf(currentFile)
if (provider) {
provider.get(currentFile, (error, content) => {
if (error) console.log(error)
self._deps.editor.setText(content)
})
} else {
console.log('cannot save ' + currentFile + '. Does not belong to any explorer')
}
}
}
module.exports = FileManager

@ -97,7 +97,8 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
if (provider) {
// TODO add approval to user for external plugin to set the content of the given `path`
provider.set(path, content, (error) => {
cb(error)
if (error) return cb(error)
fileManager.syncEditor(path)
})
} else {
cb(path + ' not available')

Loading…
Cancel
Save