diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 9b618a9fe9..f2d83d3915 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -155,9 +155,9 @@ class FileManager extends Plugin { * @param {string} path path of the directory * @returns {boolean} true if path is a directory. */ - isDirectory (path) { + async isDirectory (path) { const provider = this.fileProviderOf(path) - const result = provider.isDirectory(path) + const result = await provider.isDirectory(path) return result } @@ -362,7 +362,6 @@ class FileManager extends Plugin { path = this.limitPluginScope(path) await this._handleExists(path, `Cannot remove file or directory ${path}`) const provider = this.fileProviderOf(path) - return await provider.remove(path) } catch (e) { throw new Error(e) diff --git a/apps/remix-ide/src/app/files/remixDProvider.js b/apps/remix-ide/src/app/files/remixDProvider.js index bc59bfe90b..04b0217df1 100644 --- a/apps/remix-ide/src/app/files/remixDProvider.js +++ b/apps/remix-ide/src/app/files/remixDProvider.js @@ -38,7 +38,7 @@ module.exports = class RemixDProvider extends FileProvider { }) this._appManager.on('remixd', 'fileRenamed', (oldPath, newPath) => { - this.event.emit('fileRemoved', oldPath, newPath) + this.event.emit('fileRenamed', oldPath, newPath) }) this._appManager.on('remixd', 'rootFolderChanged', () => { @@ -141,7 +141,6 @@ module.exports = class RemixDProvider extends FileProvider { this._appManager.call('remixd', 'remove', { path: unprefixedpath }) .then(result => { const path = unprefixedpath - delete this.filesContent[path] resolve(true) this.init() diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index 24edfa1da6..dba54aef61 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -44,7 +44,6 @@ export class TabProxy extends Plugin { fileManager.events.on('fileRemoved', (name) => { const workspace = this.fileManager.currentWorkspace() - workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name) }) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index eab163b09e..66d9886a48 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -408,7 +408,7 @@ export const FileExplorer = (props: FileExplorerProps) => { try { await fileManager.remove(p) } catch (e) { - const isDir = state.fileManager.isDirectory(p) + const isDir = await state.fileManager.isDirectory(p) toast(`Failed to remove ${isDir ? 'folder' : 'file'} ${p}.`) } } diff --git a/libs/remix-ui/solidity-compiler/src/lib/css/style.css b/libs/remix-ui/solidity-compiler/src/lib/css/style.css index 3846ca0f0f..d2bbe9e606 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/css/style.css +++ b/libs/remix-ui/solidity-compiler/src/lib/css/style.css @@ -103,7 +103,6 @@ } .remixui_container { margin: 0; - margin-bottom: 2%; } .remixui_optimizeContainer { display: flex; diff --git a/libs/remixd/src/services/remixdClient.ts b/libs/remixd/src/services/remixdClient.ts index 31588628ea..8645caf4ac 100644 --- a/libs/remixd/src/services/remixdClient.ts +++ b/libs/remixd/src/services/remixdClient.ts @@ -180,12 +180,34 @@ export class RemixdClient extends PluginClient { if (!fs.existsSync(path)) return reject(new Error('File not found ' + path)) if (!isRealPath(path)) return + // Saving the content of the item{folder} before removing it + const ls = [] + try { + const resolveList = (path) => { + if (!this._isFile(path)) { + const list = utils.resolveDirectory(path, this.currentSharedFolder) + Object.keys(list).forEach(itemPath => { + if (list[itemPath].isDirectory) { + resolveList(`${this.currentSharedFolder}/${itemPath}`) + } + ls.push(itemPath) + }) + } + } + resolveList(path) + ls.push(args.path) + } catch (e) { + throw new Error(e) + } return fs.remove(path, (error: Error) => { if (error) { console.log(error) return reject(new Error('Failed to remove file/directory: ' + error)) } - this.emit('fileRemoved', args.path) + for (const file in ls) { + this.emit('fileRemoved', ls[file]) + } + resolve(true) }) }) @@ -194,10 +216,17 @@ export class RemixdClient extends PluginClient { } } + _isFile (path: string): boolean { + try { + return fs.statSync(path).isFile() + } catch (error) { + throw new Error(error) + } + } + isDirectory (args: SharedFolderArgs): boolean { try { const path = utils.absolutePath(args.path, this.currentSharedFolder) - return fs.statSync(path).isDirectory() } catch (error) { throw new Error(error) @@ -207,7 +236,6 @@ export class RemixdClient extends PluginClient { isFile (args: SharedFolderArgs): boolean { try { const path = utils.absolutePath(args.path, this.currentSharedFolder) - return fs.statSync(path).isFile() } catch (error) { throw new Error(error)