From 4041bef10acc2e3877c4156e4957f57e400a028d Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 29 Jun 2020 13:28:36 +0000 Subject: [PATCH] Call fileRenamedEvent --- src/app/files/fileManager.js | 22 +++++++--------------- test-browser/tests/fileManager_api.test.js | 3 +-- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 6699179c067..f9126122768 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -197,21 +197,10 @@ class FileManager extends Plugin { await this._handleExists(oldPath, `Cannot rename ${oldPath}`) const isFile = await this.isFile(oldPath) const newPathExists = await this.exists(newPath) - const provider = this.fileProviderOf(oldPath) - if (isFile) { - if (newPathExists) { - modalDialogCustom.alert('File already exists.') - return - } - return provider.rename(oldPath, newPath, false) - } else { - if (newPathExists) { - modalDialogCustom.alert('Folder already exists.') - return - } - return provider.rename(oldPath, newPath, true) - } + if (isFile && newPathExists) return modalDialogCustom.alert('File already exists.') + if (!isFile && newPathExists) return modalDialogCustom.alert('Folder already exists.') + return this.fileRenamedEvent(oldPath, newPath, !isFile) } /** @@ -285,7 +274,10 @@ class FileManager extends Plugin { // this.syncEditor(path) } - fileRenamedEvent (oldName, newName, isFolder) { + async fileRenamedEvent (oldName, newName, isFolder) { + const provider = this.fileProviderOf(oldName) + + await provider.rename(oldName, newName, isFolder) if (!isFolder) { this._deps.config.set('currentFile', '') this.editor.discard(oldName) diff --git a/test-browser/tests/fileManager_api.test.js b/test-browser/tests/fileManager_api.test.js index 681d354d2b3..4760869fef1 100644 --- a/test-browser/tests/fileManager_api.test.js +++ b/test-browser/tests/fileManager_api.test.js @@ -61,8 +61,7 @@ module.exports = { browser .addFile('renameFile.js', { content: executeRename }) .executeScript(`remix.exeCurrent()`) - .pause(2000) - .waitForElementPresent('[data-id="treeViewLibrowser/old_contract.sol"]') + .waitForElementPresent('[data-id="treeViewLibrowser/old_contract.sol"]', 100000) }, 'Should execute `mkdir` api from file manager external api': function (browser) {