Merge pull request #1274 from ethereum/fixSavingFile

Fix saving file
pull/1/head
yann300 7 years ago committed by GitHub
commit 971056efb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/app.js
  2. 20
      src/app/editor/editor.js
  3. 2
      src/app/files/file-explorer.js
  4. 12
      src/app/files/fileManager.js

@ -896,7 +896,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
return
}
var input = editor.get(currentFile)
if (!input) {
return
}
// if there's no change, don't do anything
if (input === previousInput) {
return

@ -169,13 +169,29 @@ function Editor (opts = {}) {
switchSession(path)
}
/**
* returns the content of the specified session @arg path
* if @arg path is not provided, the content of the current editing session is returned
*
* @param {String} path - path of th file in edition
* @return {String} content of the file referenced by @arg path
*/
this.get = function (path) {
if (currentSession === path) {
if (!path || currentSession === path) {
return editor.getValue()
} else if (sessions[path]) {
sessions[path].getValue()
}
}
this.current = function (path) {
/**
* returns the path of the currently editing file
* returns `undefined` if no session is being editer
*
* @param {String} path - path of th file in edition
* @return {String} content of the file referenced by @arg path
*/
this.current = function () {
if (editor.getSession() === emptySession) {
return
}

@ -28,7 +28,7 @@ function fileExplorer (appAPI, files) {
}
this.files.event.register('fileExternallyChanged', (path, file) => {
if (appAPI.config.get('currentFile') === path && appAPI.currentContent() !== file.content) {
if (appAPI.config.get('currentFile') === path && appAPI.currentContent() && appAPI.currentContent() !== file.content) {
modalDialog(path + ' changed', remixdDialog(),
{
label: 'Keep the content displayed in Remix',

@ -174,11 +174,13 @@ class FileManager {
var currentFile = this.opt.config.get('currentFile')
if (currentFile && this.opt.editor.current()) {
var input = this.opt.editor.get(currentFile)
var provider = this.fileProviderOf(currentFile)
if (provider) {
provider.set(currentFile, input)
} else {
console.log('cannot save ' + currentFile + '. Does not belong to any explorer')
if (input) {
var provider = this.fileProviderOf(currentFile)
if (provider) {
provider.set(currentFile, input)
} else {
console.log('cannot save ' + currentFile + '. Does not belong to any explorer')
}
}
}
}

Loading…
Cancel
Save