From 4954dca13fdbcce8476cff93992983d895fb4d05 Mon Sep 17 00:00:00 2001 From: Clinton Bloodworth Date: Fri, 13 Nov 2015 14:54:51 -0600 Subject: [PATCH] Closes #535. Do not restore editor positions if editor is destroyed. --- src/beautify.coffee | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/beautify.coffee b/src/beautify.coffee index a315f61..b9dd09d 100644 --- a/src/beautify.coffee +++ b/src/beautify.coffee @@ -430,17 +430,18 @@ handleSaveEvent = -> posArray = getCursors(editor) origScrollTop = editor.getScrollTop() beautifyFilePath(filePath, -> - buffer.reload() - logger.verbose('restore editor positions', posArray,origScrollTop) - # Let the scrollTop setting run after all the save related stuff is run, - # otherwise setScrollTop is not working, probably because the cursor - # addition happens asynchronously - setTimeout ( -> - setCursors(editor, posArray) - editor.setScrollTop(origScrollTop) - # console.log "setScrollTop" - return - ), 0 + if editor.alive and editor.alive isnt false + buffer.reload() + logger.verbose('restore editor positions', posArray,origScrollTop) + # Let the scrollTop setting run after all the save related stuff is run, + # otherwise setScrollTop is not working, probably because the cursor + # addition happens asynchronously + setTimeout ( -> + setCursors(editor, posArray) + editor.setScrollTop(origScrollTop) + # console.log "setScrollTop" + return + ), 0 ) ) plugin.subscriptions.add disposable