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()