mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Add Pane.destroyItem and rename removeActiveItem -> destroyActiveItem
Pane.removeItem removes an item, but no longer tries to call destroy on it. This will facilitate moving items between panes.
This commit is contained in:
committed by
probablycorey
parent
61fa393e03
commit
2e2ff3a1d0
@@ -20,7 +20,7 @@ class Pane extends View
|
||||
@viewsByClassName = {}
|
||||
@showItem(@items[0])
|
||||
|
||||
@command 'core:close', @removeActiveItem
|
||||
@command 'core:close', @destroyActiveItem
|
||||
@command 'pane:show-next-item', @showNextItem
|
||||
@command 'pane:show-previous-item', @showPreviousItem
|
||||
@command 'pane:split-left', => @splitLeft()
|
||||
@@ -89,17 +89,21 @@ class Pane extends View
|
||||
@trigger 'pane:item-added', [item, index]
|
||||
item
|
||||
|
||||
removeActiveItem: =>
|
||||
@removeItem(@activeItem)
|
||||
destroyActiveItem: =>
|
||||
@destroyItem(@activeItem)
|
||||
false
|
||||
|
||||
destroyItem: (item) ->
|
||||
@removeItem(item)
|
||||
item.destroy?()
|
||||
|
||||
removeItem: (item) ->
|
||||
index = @items.indexOf(item)
|
||||
return if index == -1
|
||||
|
||||
@showNextItem() if item is @activeItem and @items.length > 1
|
||||
_.remove(@items, item)
|
||||
item.destroy?()
|
||||
|
||||
@cleanupItemView(item)
|
||||
@trigger 'pane:item-removed', [item, index]
|
||||
@remove() unless @items.length
|
||||
|
||||
Reference in New Issue
Block a user