mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Only move legit items to the top of the stack
Fixes #11002 cc @natalieogle
This commit is contained in:
@@ -337,6 +337,10 @@ describe "Pane", ->
|
||||
expect(pane.itemStack).toEqual [item2]
|
||||
expect(pane.getActiveItem()).toBe item2
|
||||
|
||||
pane.destroyItem(item2)
|
||||
expect(pane.itemStack).toEqual []
|
||||
expect(pane.getActiveItem()).toBeUndefined()
|
||||
|
||||
it "invokes ::onWillDestroyItem() observers before destroying the item", ->
|
||||
events = []
|
||||
pane.onWillDestroyItem (event) ->
|
||||
|
||||
@@ -307,6 +307,7 @@ class Pane extends Model
|
||||
|
||||
# Add item (or move item) to the end of the itemStack
|
||||
addItemToStack: (newItem) ->
|
||||
return unless newItem?
|
||||
index = @itemStack.indexOf(newItem)
|
||||
@itemStack.splice(index, 1) unless index is -1
|
||||
@itemStack.push(newItem)
|
||||
|
||||
Reference in New Issue
Block a user