mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
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:
committed by
Antonio Scandurra
parent
45bd466384
commit
c7a4755808
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user