Fix #1948, #1949. Fix beautify on save when text has not changed

This commit is contained in:
Glavin Wiechert 2017-11-22 10:50:47 -04:00
parent d068bfe0b3
commit c6760ef3fe
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,9 @@
# Next
- ...
# v0.30.9 (2017-11-22)
- Fix [#1949](https://github.com/Glavin001/atom-beautify/issues/1949): Fix beautify on save when text has not changed.
# v0.30.8 (2017-11-22)
- Fix [#1949](https://github.com/Glavin001/atom-beautify/issues/1949): Fix beautify on save when text has not changed.

View File

@ -96,9 +96,10 @@ beautify = ({ editor, onSave, language }) ->
if not text?
# Do nothing, is undefined
# console.log 'beautifyCompleted'
return resolve(text)
else if text instanceof Error
showError(text)
return reject(text)
return resolve(text)
else if typeof text is "string"
if oldText isnt text
@ -127,15 +128,18 @@ beautify = ({ editor, onSave, language }) ->
# otherwise setScrollTop is not working, probably because the cursor
# addition happens asynchronously
setTimeout ( ->
# console.log "setScrollTop"
setScrollTop editor, origScrollTop
return resolve(text)
), 0
else
return setTimeout(() ->
resolve(text)
, 0)
else
error = new Error("Unsupported beautification result '#{text}'.")
showError(error)
return setTimeout(-> resolve(text), 0)
return resolve(text)
# else
# console.log "Already Beautiful!"