mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Chain promises better
This commit is contained in:
@@ -192,15 +192,14 @@ class Project
|
||||
#
|
||||
# Returns a promise that resolves to an {EditSession}.
|
||||
openAsync: (filePath, options={}) ->
|
||||
for opener in @openers
|
||||
return Q(resource) if resource = opener(filePath, options)
|
||||
resource = null
|
||||
_.find @openers, (opener) -> resource = opener(filePath, options)
|
||||
|
||||
deferred = Q.defer()
|
||||
@bufferForPathAsync(filePath).then (buffer) =>
|
||||
editSession = @buildEditSessionForBuffer(buffer, options)
|
||||
deferred.resolve(editSession)
|
||||
|
||||
deferred.promise
|
||||
if resource
|
||||
Q(resource)
|
||||
else
|
||||
@bufferForPathAsync(filePath).then (buffer) =>
|
||||
editSession = @buildEditSessionForBuffer(buffer, options)
|
||||
|
||||
# Private: DEPRECATED
|
||||
open: (filePath, options={}) ->
|
||||
|
||||
@@ -75,7 +75,7 @@ class TextBuffer
|
||||
@updateCachedDiskContentsAsync().then =>
|
||||
@reload() if @loadFromDisk and @isModified()
|
||||
@text.clearUndoStack()
|
||||
Q(this)
|
||||
this
|
||||
|
||||
### Internal ###
|
||||
|
||||
|
||||
Reference in New Issue
Block a user