Commit 4dd7f3f5 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #748 from ethereum/fixRenamingFile

Fix renaming file
parents 305cf112 2f298236
......@@ -46,6 +46,7 @@ var css = csjs`
module.exports = fileExplorer
function fileExplorer (appAPI, files) {
var self = this
this.files = files
function remixdDialog () {
......@@ -203,7 +204,7 @@ function fileExplorer (appAPI, files) {
var label = this
var li = getLiFrom(label)
var classes = li.className
if (~classes.indexOf('hasFocus') && !label.getAttribute('contenteditable')) {
if (~classes.indexOf('hasFocus') && !label.getAttribute('contenteditable') && label.getAttribute('data-path') !== self.files.type) {
textUnderEdit = label.innerText
label.setAttribute('contenteditable', true)
label.classList.add(css.rename)
......@@ -223,8 +224,11 @@ function fileExplorer (appAPI, files) {
newPath = newPath.split('/')
newPath[newPath.length - 1] = label.innerText
newPath = newPath.join('/')
if (label.innerText.match(/(\/|:|\*|\?|"|<|>|\\|\||')/) !== null) {
modalDialogCustom.alert('special characters are not allowsed')
if (label.innerText === '') {
modalDialogCustom.alert('File name cannot be empty')
label.innerText = textUnderEdit
} else if (label.innerText.match(/(\/|:|\*|\?|"|<|>|\\|\||')/) !== null) {
modalDialogCustom.alert('Special characters are not allowed')
label.innerText = textUnderEdit
} else if (!files.exists(newPath)) {
files.rename(label.dataset.path, newPath, isFolder)
......
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