Add config.editor.autosave

This commit is contained in:
Nathan Sobo
2012-12-16 11:30:06 -08:00
parent d311dac39f
commit 4538a70859
2 changed files with 4 additions and 3 deletions

View File

@@ -1939,9 +1939,9 @@ describe "Editor", ->
describe "when autosave is enabled", ->
it "autosaves the current buffer when the editor loses focus or switches edit sessions", ->
config.update("editor.autosave", true)
rootView.attachToDom()
editor2 = editor.splitRight()
rootView.autosave = true
spyOn(editor2.activeEditSession, 'save')
editor.focus()

View File

@@ -18,6 +18,7 @@ class Editor extends View
@configDefaults:
fontSize: 20
showInvisibles: false
autosave: false
@content: (params) ->
@div class: @classes(params), tabindex: -1, =>
@@ -323,7 +324,7 @@ class Editor extends View
@hiddenInput.on 'focusout', =>
@isFocused = false
@removeClass 'focused'
@autosave() if @rootView()?.autosave
@autosave() if config.editor.autosave
@overlayer.on 'mousedown', (e) =>
@overlayer.hide()
@@ -449,7 +450,7 @@ class Editor extends View
throw new Error("Edit session not found") unless @editSessions[index]
if @activeEditSession
@autosave() if @rootView()?.autosave
@autosave() if config.editor.autosave
@saveScrollPositionForActiveEditSession()
@activeEditSession.off(".editor")