From 3c36f51fe65f843899c069206bffbbfcfb3aa7dd Mon Sep 17 00:00:00 2001 From: Seongjae Lee Date: Thu, 23 Jun 2016 22:38:00 -0700 Subject: [PATCH] Add an option to enable/disable autosave, resolving #50 It would be more efficient if we can subscribe/unsubscribe autosave whenver this parameter is changed, but I don't think the current implementation would be that expansive. --- lib/notational-velocity.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/notational-velocity.coffee b/lib/notational-velocity.coffee index 46e385b..ce024d6 100644 --- a/lib/notational-velocity.coffee +++ b/lib/notational-velocity.coffee @@ -23,7 +23,11 @@ module.exports = description: 'Lunr pipeline preprocesses query to make search faster. However, it will skip searching some of stop words such as "an" or "be".' type: 'boolean' default: true - + enableAutosave: + title: 'Enable Autosave' + description: 'Enable saving the document automatically whenever the user leaves the window or change the tab.' + type: 'boolean' + default: true activate: (state) -> @rootDirectory = @ensureNoteDirectory() @@ -64,6 +68,7 @@ module.exports = @notationalVelocityView autosave: (paneItem) -> + return unless atom.config.get('nvatom.enableAutosave') return unless paneItem?.getURI?()? return unless paneItem?.isModified?() uri = paneItem.getURI() @@ -81,6 +86,7 @@ module.exports = return true autosaveAll: -> + return unless atom.config.get('nvatom.enableAutosave') @autosave(paneItem) for paneItem in atom.workspace.getPaneItems() ensureNoteDirectory: ->