Commit 44091ec2 authored by chriseth's avatar chriseth Committed by GitHub

Merge pull request #427 from ethereum/sync-on-switch

Sync file on tab switch
parents b97b56f3 d91467b9
......@@ -299,6 +299,8 @@ var run = function () {
editor.event.register('sessionSwitched', refreshTabs)
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