From c6760ef3fea927d0e996bf2aaa201e4c73f46f38 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Wed, 22 Nov 2017 10:50:47 -0400 Subject: [PATCH] Fix #1948, #1949. Fix beautify on save when text has not changed --- CHANGELOG.md | 3 +++ src/beautify.coffee | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08a4359..a674ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/beautify.coffee b/src/beautify.coffee index bae3f81..af517ec 100644 --- a/src/beautify.coffee +++ b/src/beautify.coffee @@ -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!"