Description
Describe the bug
Unsaved changes to the sketch will be lost when closing the window. For this reason, the IDE must request confirmation from the user before proceeding, as is the standard convention for any application.
🐛 The IDE closes without confirmation even when the sketch has unsaved changes. This may cause loss of data for users who expect the standard "save and quit" behavior.
To Reproduce
- Open any sketch.
- Select File > Preferences... from the Arduino IDE menus.
- Uncheck the box next to "🗹 Auto save".
- Click the OK button.
- Make any change to the sketch.
❗ Do not save the sketch. - Select File > Close from the Arduino IDE menus.
🐛 The window closes immediately and all unsaved changes are lost.
Expected behavior
Confirmation dialog when closing IDE window with unsaved changes.
Desktop
Original
- OS: Windows 10, Ubuntu 20.04
- Version: 2.0.0-rc4-snapshot-0207778
Date: 2022-02-23T15:40:32.443Z
CLI Version: 0.21.0 [10107d24]
Last verified with
- OS: Windows 10, Ubuntu 20.04
- Version: 2.0.0-rc4-snapshot-70f1c5f
Date: 2022-03-09T10:47:19.505Z
CLI Version: 0.21.0 [10107d24]
Additional context
I bisected the bug to 112153f (it does not occur when using the build from the previous commit 69ac1f4).
The bug occurs no matter which method you use to close the window:
- File > Close
- File > Quit
- Native window close control
The bug also occurs with new sketches that have unsaved changes when the sketch is closed by these methods:
- File > Quit
- Native window close control
(There is a dialog on File > Close with a new dirty sketch)
Originally reported by @UKHeliBob at https://forum.arduino.cc/t/no-prompt-to-save-a-modified-file-when-closing-the-ide/962323