From e94430630ca05e0a66ebf3baaee413e4da66776e Mon Sep 17 00:00:00 2001 From: Jonathan Hoyt Date: Sat, 9 May 2015 13:49:42 -0700 Subject: [PATCH] Save in editor.onDidStopChanging Temporarily disables whitespace package so that you can create newlines without getting them removed on autosave. --- lib/notational-velocity-view.coffee | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/notational-velocity-view.coffee b/lib/notational-velocity-view.coffee index ac14cd8..3301d14 100644 --- a/lib/notational-velocity-view.coffee +++ b/lib/notational-velocity-view.coffee @@ -87,16 +87,24 @@ class NotationalVelocityView extends SelectListView confirmSelection: -> item = @getSelectedItem() + filePath = null if item? - atom.workspace.open(item.getFilePath()) - @cancel() + filePath = item.getFilePath() else sanitizedQuery = @getFilterQuery().replace(/\s+$/, '') if sanitizedQuery.length > 0 filePath = path.join(@rootDirectory, sanitizedQuery + '.md') fs.writeFileSync(filePath, '') - atom.workspace.open(filePath) - @cancel() + + if filePath + atom.workspace.open(filePath).then (editor) -> + editor.onDidStopChanging () -> + if editor.isModified() + atom.packages.deactivatePackage("whitespace"); + editor.save() + atom.packages.activatePackage("whitespace"); + + @cancel() destroy: -> @cancel()