From b5cb054b3976288785051b11b2a2ab6365fce32d Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Thu, 27 Jul 2017 15:58:50 +0200 Subject: [PATCH] Support Promise response in trySave In Atom 1.19, TextBuffer.save returns a Promise. This commit adds support to catch this and resolve our internal callbacks when promise resolves. --- lib/ex.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index e026b96..4b13d1a 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -17,8 +17,13 @@ trySave = (func) -> deferred = defer() try - func() - deferred.resolve() + response = func() + + if response instanceof Promise + response.then -> + deferred.resolve() + else + deferred.resolve() catch error if error.message.endsWith('is a directory') atom.notifications.addWarning("Unable to save file: #{error.message}") @@ -252,7 +257,7 @@ class Ex @write(args) wq: (args) => - @write(args).then => @quit() + @write(args).then(=> @quit()) wa: => @wall()