Skip to content

Commit

Permalink
Call fileRenamedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
ioedeveloper committed Jun 29, 2020
1 parent 1b2bac5 commit 4041bef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
22 changes: 7 additions & 15 deletions src/app/files/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions test-browser/tests/fileManager_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4041bef

Please sign in to comment.