Skip to content

Save fails silently when sketch out of sync with file system #2051

Closed
@per1234

Description

@per1234

Describe the problem

When the "Auto save" preference is disabled, any changes to a sketch made in the Arduino IDE editor are "staged" in memory until the user manually saves the sketch. The sketch file can be modified externally during that time. These conditions pose a danger of user data being lost when the sketch is saved.

When the user attempts to save the sketch under these conditions Arduino IDE detects the out of sync state and displays a dialog notifying the user of the situation and asking how to proceed:

image

🐛 If the user clicks the "YES" button in the dialog to indicate they wish to write the version of the sketch from the editor to disk, the write does not occur contrary to the user's directive.

To reproduce

  1. Select File > New Sketch from the Arduino IDE menus.
  2. Select File > Save As... from the Arduino IDE menus.
  3. Save the sketch with the name "UnsyncedSketch".
  4. Select File > Preferences from the Arduino IDE menus.
  5. Uncheck the box next to " Auto save"
  6. Click the OK button.
  7. Make an identifiable change to the sketch:
    // change made in IDE
    ❗ Do not save the sketch.
  8. Open UnsyncedSketch/UnsyncedSketch.ino in a text editor.
  9. Make an identifiable change to the sketch:
    // change made externally
  10. Save the file in the text editor.
  11. Select File > Save from the Arduino IDE menus.
    The "The file 'UnsyncedSketch.ino' has been changed on the file system." dialog opens.
  12. Click the YES button in the dialog.

🐛 The change made in the IDE editor is not saved to disk.
🐛 There is no indication to the user that their data was not saved other than the ("dirty" state indicator) remaining on the sketch tab.

Expected behavior

When the user directs Arduino IDE to write the sketch to disk, it does so.

Arduino IDE version

964ea3b

Operating system

Windows

Operating system version

11

Additional context

I bisected the regression to e4beb03 (does not occur with the build of the previous commit dafb245).


Nothing is printed to the logs when the save fails.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions