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