Unverified Commit 971056ef authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1274 from ethereum/fixSavingFile

Fix saving file
parents 9f86012b 954c52b8
......@@ -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,6 +174,7 @@ class FileManager {
var currentFile = this.opt.config.get('currentFile')
if (currentFile && this.opt.editor.current()) {
var input = this.opt.editor.get(currentFile)
if (input) {
var provider = this.fileProviderOf(currentFile)
if (provider) {
provider.set(currentFile, input)
......@@ -182,6 +183,7 @@ class FileManager {
}
}
}
}
}
module.exports = FileManager
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment