Merge pull request #15264 from captbaritone/pane-destroy-item

Ensure Pane.destroyItem always returns a promise
This commit is contained in:
Max Brunsfeld
2017-08-12 13:04:35 -07:00
committed by GitHub
2 changed files with 20 additions and 10 deletions

View File

@@ -621,12 +621,15 @@ class Pane
destroyItem: (item, force) ->
index = @items.indexOf(item)
if index isnt -1
return false if not force and @getContainer()?.getLocation() isnt 'center' and item.isPermanentDockItem?()
if not force and @getContainer()?.getLocation() isnt 'center' and item.isPermanentDockItem?()
return Promise.resolve(false)
@emitter.emit 'will-destroy-item', {item, index}
@container?.willDestroyPaneItem({item, index, pane: this})
if force or not item?.shouldPromptToSave?()
@removeItem(item, false)
item.destroy?()
Promise.resolve(true)
else
@promptToSaveItem(item).then (result) =>
if result