Fixes #289. Remove deprecated subscription call to TextBuffer.on

Also `beautify on save` is checked on every save,
not just on Atom Beautify activation / startup.
This commit is contained in:
Glavin Wiechert 2015-05-05 13:01:58 -03:00
parent 57ffa6741f
commit bdb1fc0d38
1 changed files with 5 additions and 6 deletions

View File

@ -43,6 +43,9 @@ setCursors = (editor, posArray) ->
return
beautify = ({onSave}) ->
# Verify if beautify on save
return if onSave and atom.config.get("atom-beautify.beautifyOnSave") is false
# Continue beautifying
path ?= require("path")
LoadingView ?= require "./views/loading-view"
@loadingView ?= new LoadingView()
@ -327,12 +330,8 @@ debug = () ->
handleSaveEvent = =>
atom.workspace.observeTextEditors (editor) =>
buffer = editor.getBuffer()
plugin.unsubscribe buffer
if atom.config.get("atom-beautify.beautifyOnSave")
events = "will-be-saved"
plugin.subscribe buffer, events, beautify.bind(@, {onSave:true})
return
return
disposable = buffer.onWillSave(beautify.bind(@, {onSave:true}))
plugin.subscribe disposable
{Subscriber} = require path.join(atom.packages.resourcePath, 'node_modules', 'emissary')
Subscriber.extend plugin