destradax / scratch

A simple scratch for Github's Atom
MIT License
7 stars 2 forks source link

Gracefully close with hotkey when scratch has been modified #14

Closed nholden closed 5 years ago

nholden commented 5 years ago

Background

I reported this bug in https://github.com/destradax/scratch/issues/13. With autosave disabled, if a user modifies their scratch and uses the hotkey to close it, the TextEditor is destroyed before the user is prompted to save. When the user then clicks save in the prompt, they see an error:

46265828-1e4e5000-c4df-11e8-811c-c29e5ddefc90

The fix

This change uses the Pane destroyItem function to ensure that when a user without autosave enabled closes their scratch with the hotkey, it will remain open until they have chosen "Save," "Don't Save," or "Cancel."

This is the same behavior as when the user clicks the "X" on the tab to close their scratch. It does not impact the behavior for users with autosave enabled. I suspect that this change is less brittle to future API changes because the destroyItem function is publicly documented while promptToSaveItem is not.

Before demo

46265830-25755e00-c4df-11e8-9caf-b9a2a69ab735

After demo

fix-demo

closes https://github.com/destradax/scratch/issues/13

destradaxcheckapp commented 5 years ago

Hi, I'll be getting back to this issue (and the others currently open) during this week

destradax commented 5 years ago

Merged for version 1.2.2