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:
parent
4747bcf5e8
commit
b5cb054b39
1 changed files with 8 additions and 3 deletions
|
|
@ -17,8 +17,13 @@ trySave = (func) ->
|
||||||
deferred = defer()
|
deferred = defer()
|
||||||
|
|
||||||
try
|
try
|
||||||
func()
|
response = func()
|
||||||
deferred.resolve()
|
|
||||||
|
if response instanceof Promise
|
||||||
|
response.then ->
|
||||||
|
deferred.resolve()
|
||||||
|
else
|
||||||
|
deferred.resolve()
|
||||||
catch error
|
catch error
|
||||||
if error.message.endsWith('is a directory')
|
if error.message.endsWith('is a directory')
|
||||||
atom.notifications.addWarning("Unable to save file: #{error.message}")
|
atom.notifications.addWarning("Unable to save file: #{error.message}")
|
||||||
|
|
@ -252,7 +257,7 @@ class Ex
|
||||||
@write(args)
|
@write(args)
|
||||||
|
|
||||||
wq: (args) =>
|
wq: (args) =>
|
||||||
@write(args).then => @quit()
|
@write(args).then(=> @quit())
|
||||||
|
|
||||||
wa: =>
|
wa: =>
|
||||||
@wall()
|
@wall()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue