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:
The fix
This change uses the PanedestroyItem 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.
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: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 whilepromptToSaveItem
is not.Before demo
After demo
closes https://github.com/destradax/scratch/issues/13