From 4538a7085914ffec8ea4c6cb449ac3ac36403207 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sun, 16 Dec 2012 11:30:06 -0800 Subject: [PATCH] Add `config.editor.autosave` --- spec/app/editor-spec.coffee | 2 +- src/app/editor.coffee | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index f127fc7ce..60df5c54b 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index e7a42fc08..a0d524f17 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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")