Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Return true from Pane#destroyItem if item is destroyed #14884

Closed
wants to merge 2 commits into from

Conversation

kuychaco
Copy link
Contributor

This PR ensures that we return the correct boolean value from Pane.prototype.destroyItem when the force parameter is true or the item should not prompt to save.

Without this, logic such as the following

const destroyed = await pane.destroyItem(item); // returns the value of `item.destroy && item.destroy()` which can be undefined or null
if (!destroyed) {
  pane.activateItem(item); // called on an item that has been destroyed
}

... produces an uncaught error error ...

Uncaught (in promise) Error: Adding a pane item with URI '/some/path/to/item' that has already been destroyed

/cc @maxbrunsfeld for relevant change made in dc32018#diff-1a7d1dda35d8e7ed3ad35b9a9fd2f134L615

NOTE: Fix needs to be cherry-picked to beta on the 1.9-releases branch in order for atom/github CI to pass

Per documentation, this method:
`Returns a {Promise} that resolves with a {Boolean} indicating whether
or not the item was destroyed.`
kuychaco added a commit to atom/github that referenced this pull request Jun 24, 2017
@maxbrunsfeld
Copy link
Contributor

👍 Thanks for fixing this @kuychaco!

@kuychaco
Copy link
Contributor Author

Somehow this got missed when atom/github#980 got merged, and is now superseded by #15264 so I'll go ahead and close it

@kuychaco kuychaco closed this Aug 25, 2017
@jasonrudolph jasonrudolph deleted the ku-fix-destroy-item-bug branch October 28, 2017 00:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants