If Workspace.open finds existing item, yield event loop

This ensures that the function always behaves asynchronously regardless
of the state of the workspace.

/cc @maxbrunsfeld

Signed-off-by: Antonio Scandurra <as-cii@github.com>
This commit is contained in:
Nathan Sobo
2017-03-29 09:27:21 -06:00
committed by Antonio Scandurra
parent 45bd466384
commit c7a4755808

View File

@@ -670,8 +670,12 @@ module.exports = class Workspace extends Model {
if (pane) item = pane.itemForURI(uri)
}
// Create an item if one was not found.
if (!item) {
// If an item is already present, yield the event loop to ensure this method
// is consistently asynchronous regardless of the workspace state. If no
// item is present, create one.
if (item) {
await Promise.resolve()
} else {
item = await this.createItemForURI(uri, options)
if (!item) return