Commit d91467b9 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Sync file on tab switch

parent e064f0d7
......@@ -299,6 +299,8 @@ var run = function () {
editor.event.register('sessionSwitched', updateFiles)
function switchToFile (file) {
editorSyncFile()
currentFile = file
if (files.isReadOnly(file)) {
......@@ -659,6 +661,11 @@ var run = function () {
compiler.compile(files, target)
}
function editorSyncFile () {
var input = editor.get(currentFile)
files.set(currentFile, input)
}
var previousInput = ''
var compileTimeout = null
var saveTimeout = null
......@@ -677,10 +684,7 @@ var run = function () {
if (saveTimeout) {
window.clearTimeout(saveTimeout)
}
saveTimeout = window.setTimeout(function () {
var input = editor.get(currentFile)
files.set(currentFile, input)
}, 5000)
saveTimeout = window.setTimeout(editorSyncFile, 5000)
// special case: there's nothing else to do
if (input === '') {
......
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