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.
This commit is contained in:
Edvin Hultberg 2017-07-27 15:58:50 +02:00
parent 4747bcf5e8
commit b5cb054b39

View file

@ -17,7 +17,12 @@ trySave = (func) ->
deferred = defer()
try
func()
response = func()
if response instanceof Promise
response.then ->
deferred.resolve()
else
deferred.resolve()
catch error
if error.message.endsWith('is a directory')
@ -252,7 +257,7 @@ class Ex
@write(args)
wq: (args) =>
@write(args).then => @quit()
@write(args).then(=> @quit())
wa: =>
@wall()