Add Workspace::onWillDestroyPaneItem

It is needed by the autosave package which previously relied on DOM
bubbling to coalesce events from various panes.
This commit is contained in:
Nathan Sobo
2014-12-01 10:39:09 -07:00
parent 3d3521962c
commit 7dc9d0c8ce
4 changed files with 53 additions and 6 deletions

View File

@@ -371,7 +371,7 @@ class Pane extends Model
@items.splice(index, 1)
@emit 'item-removed', item, index, destroyed
@emitter.emit 'did-remove-item', {item, index, destroyed}
@container?.paneItemDestroyed(item) if destroyed
@container?.didDestroyPaneItem({item, index, pane: this}) if destroyed
@destroy() if @items.length is 0 and atom.config.get('core.destroyEmptyPanes')
# Public: Move the given item to the given index.
@@ -410,6 +410,7 @@ class Pane extends Model
if index isnt -1
@emit 'before-item-destroyed', item
@emitter.emit 'will-destroy-item', {item, index}
@container?.willDestroyPaneItem({item, index, pane: this})
if @promptToSaveItem(item)
@removeItem(item, true)
item.destroy?()