From e891772417ea513efb66061e61629377f07b4fdb Mon Sep 17 00:00:00 2001 From: serapath Date: Thu, 25 Jan 2018 05:30:10 +0800 Subject: [PATCH] fix file explorer update events 1/2 --- src/app.js | 2 +- src/app/files/browser-files.js | 12 ++++++++---- src/app/files/file-explorer.js | 33 ++++++++++++++++++--------------- src/app/files/shared-folder.js | 1 + 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/app.js b/src/app.js index 9db3e79058..5a15ec9817 100644 --- a/src/app.js +++ b/src/app.js @@ -497,7 +497,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org switchFile: function (path) { fileManager.switchFile(path) }, - event: this.event, + event: fileManager.event, currentFile: function () { return config.get('currentFile') }, diff --git a/src/app/files/browser-files.js b/src/app/files/browser-files.js index ac0504e4aa..2e22536708 100644 --- a/src/app/files/browser-files.js +++ b/src/app/files/browser-files.js @@ -118,19 +118,21 @@ function Files (storage) { this.resolveDirectory = function (path, callback) { var self = this if (path[0] === '/') path = path.substring(1) + if (path[0] === '.' && path[1] === '/') path = path.substring(2) if (!path) return callback(null, { [self.type]: { } }) + path = self.removePrefix('' + (path || '')) var filesList = {} var tree = {} // add r/w filesList to the list storage.keys().forEach((path) => { // NOTE: as a temporary measure do not show the config file if (path !== '.remix.config') { - filesList[self.type + '/' + path] = false + filesList[path] = false } }) // add r/o files to the list Object.keys(readonly).forEach((path) => { - filesList[self.type + '/' + path] = true + filesList[path] = true }) Object.keys(filesList).forEach(function (path) { @@ -139,7 +141,7 @@ function Files (storage) { '/content': self.get(path) }) }) - return callback(null, tree[path] || {}) + return callback(null, tree) function hashmapize (obj, path, val) { var nodes = path.split('/') var i = 0 @@ -155,7 +157,9 @@ function Files (storage) { } this.removePrefix = function (path) { - return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path + path = path.indexOf(this.type) === 0 ? path.replace(this.type, '') : path + if (path[0] === '/') return path.substring(1) + return path } // rename .browser-solidity.json to .remix.config diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 15baaf437d..29377b092c 100755 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -53,6 +53,8 @@ var css = csjs` ` module.exports = fileExplorer +var focusElement = null + function fileExplorer (appAPI, files) { var self = this this.files = files @@ -101,7 +103,7 @@ function fileExplorer (appAPI, files) { } }, formatSelf: function formatSelf (key, data, li) { - var isRoot = data.path.indexOf('/') === -1 + var isRoot = data.path === self.files.type return yo`