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