Commit 7bf15f39 authored by yann300's avatar yann300

fix renaming/removal

parent 3b611d07
...@@ -281,6 +281,7 @@ var run = function () { ...@@ -281,6 +281,7 @@ var run = function () {
if (!files.rename(originalName, newName)) { if (!files.rename(originalName, newName)) {
alert('Error while renaming file') alert('Error while renaming file')
} else { } else {
currentFile = null
switchToFile(newName) switchToFile(newName)
editor.discard(originalName) editor.discard(originalName)
} }
...@@ -301,6 +302,7 @@ var run = function () { ...@@ -301,6 +302,7 @@ var run = function () {
if (!files.remove(name)) { if (!files.remove(name)) {
alert('Error while removing file') alert('Error while removing file')
} else { } else {
currentFile = null
switchToNextFile() switchToNextFile()
editor.discard(name) editor.discard(name)
} }
...@@ -666,23 +668,28 @@ var run = function () { ...@@ -666,23 +668,28 @@ var run = function () {
function runCompiler () { function runCompiler () {
var files = {} var files = {}
if (currentFile) {
var target = currentFile var target = currentFile
files[target] = editor.get(currentFile) files[target] = editor.get(currentFile)
compiler.compile(files, target) compiler.compile(files, target)
} }
}
function editorSyncFile () { function editorSyncFile () {
if (currentFile) {
var input = editor.get(currentFile) var input = editor.get(currentFile)
files.set(currentFile, input) files.set(currentFile, input)
} }
}
var previousInput = '' var previousInput = ''
var compileTimeout = null var compileTimeout = null
var saveTimeout = null var saveTimeout = null
function editorOnChange () { function editorOnChange () {
if (!currentFile) {
return
}
var input = editor.get(currentFile) var input = editor.get(currentFile)
// if there's no change, don't do anything // if there's no change, don't do anything
......
...@@ -58,7 +58,7 @@ function Files (storage) { ...@@ -58,7 +58,7 @@ function Files (storage) {
} }
this.isReadOnly = function (path) { this.isReadOnly = function (path) {
return !!readonly[path] return readonly[path] !== undefined
} }
this.remove = function (path) { this.remove = function (path) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
function Storage () { function Storage () {
this.exists = function (name) { this.exists = function (name) {
return !!this.get(name) return this.get(name) !== null
} }
this.get = function (name) { this.get = function (name) {
......
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