Pending pane items shouldn't be made permanent before being replaced

Previously, when a Pane would replace a pending item with
another pending item, it would emit
`onItemDidTerminatePendingState` for that item, which was
not true because the item was actually being destroyed.
This commit is contained in:
Michelle Tilley
2016-04-02 17:48:24 -07:00
parent f1cf66ba32
commit 8575b38c7b
2 changed files with 25 additions and 3 deletions

View File

@@ -442,15 +442,16 @@ class Pane extends Model
if typeof item.onDidTerminatePendingState is "function"
itemSubscriptions.add item.onDidTerminatePendingState =>
@clearPendingItem() if @getPendingItem() is item
itemSubscriptions.add item.onDidDestroy => @removeItem(item, false)
@subscriptionsPerItem.set item, itemSubscriptions
@items.splice(index, 0, item)
lastPendingItem = @getPendingItem()
replacingPendingItem = lastPendingItem? and not moved
@pendingItem = null if replacingPendingItem
@setPendingItem(item) if pending
@emitter.emit 'did-add-item', {item, index, moved}
@destroyItem(lastPendingItem) if lastPendingItem? and not moved
@destroyItem(lastPendingItem) if replacingPendingItem
@setActiveItem(item) unless @getActiveItem()?
item
@@ -458,7 +459,8 @@ class Pane extends Model
if @pendingItem isnt item
mostRecentPendingItem = @pendingItem
@pendingItem = item
@emitter.emit 'item-did-terminate-pending-state', mostRecentPendingItem
if mostRecentPendingItem?
@emitter.emit 'item-did-terminate-pending-state', mostRecentPendingItem
getPendingItem: =>
@pendingItem or null