Skip to content

"Are you sure you want to close the sketch?" message when doing "Save as" with dirty sketch #38

Closed
@ubidefeo

Description

@ubidefeo

Describe the bug

If a "Save As..." is done when the sketch is in an unsaved (AKA "dirty") state, the IDE presents an unexpected "Are you sure you want to close the sketch?" dialog.

Regardless of which choice the user selects in the dialog, the resulting sketch files do not contain the unsaved changes that were in the editor.

To Reproduce

  1. Select File > Preferences from the Arduino IDE menus.
  2. Uncheck the box next to "☐ Auto save"
  3. Click the OK button.
  4. Select File > New from the Arduino IDE menus.
  5. Make some change to the sketch and do not save.
  6. Select File > Save As... from the Arduino IDE menus.
  7. Click the Save button.
    An "Are you sure you want to close the sketch?" message is shown unexpectedly, since you did not do anything that would be considered a close operation.
  8. Click the Yes button.
    The IDE window now closes.
  9. Open the sketch you saved via the "Save As..." operation.
  10. Check whether the change you made is present.
    It is not!
  11. Select File > Save As... from the Arduino IDE menus.
  12. Click the Save button.
    An "Are you sure you want to close the sketch?" message is shown unexpectedly, since you did not do anything that would be considered a close operation.
  13. Click the No button.
  14. Open the sketch you saved via the "Save As..." operation.
  15. Check whether the change you made is present.
    It is not!

Expected behavior

The exact contents of the sketch that is open in the editor are always saved to the sketch specified via the "Save As..." operation, regardless of dirty state.

No "Are you sure you want to close the sketch?" dialog is shown during this procedure.

The currently open sketch is replaced by the new sketch created by the "Save As..." process, just as it does after "Save As..." with a non-dirty sketch.

Desktop

  • OS: Windows 10
  • Version: 2.0.0-rc1-snapshot.be55a0a
    Date: 2021-12-03T11:09:57.266Z
    CLI Version: 0.20.1 [abb21449]

Additional context

[ originally reported by @per1234 ]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions