Closed
Description
Describe the problem
The name of the primary source file of a sketch must match the sketch folder. For this reason, the IDE's "Save As..." function does two things:
- Saves the sketch files to a folder of the selected name (e.g.,
FooSketch
). - Renames the primary source file to match the new sketch name (e.g.,
FooSketch.ino
).
This introduces the possibility of a collision between the target primary source file name and existing secondary source files of the sketch.
🙂 When such a collision occurs while using Arduino IDE 1.x, the operation is halted and the problem clearly communicated to the user:
🐛 When such a collision occurs while using Arduino IDE 2.x, the secondary source file is silently overwritten.
To reproduce
- Select File > New from the Arduino IDE menus.
- Click the ▼ button on the right side of the editor tabs bar.
- Select "New Tab" from the menu.
- Create a tab named Foo.ino
- Add some unique content to the tab:
// Foo.ino tab content
- Select File > Save As... from the Arduino IDE menus.
- Save the sketch as
Foo
🐛 The sketch now contains only a single file Foo.ino
, with the contents from the primary source file. The previous contents of the Foo.ino
secondary source file have been lost.
Expected behavior
- Halt the operation that would result in data loss.
- Clearly communicate the problem to the user.
-OR-
- Request confirmation from the user before overwriting the file.
Arduino IDE version
Original report
2.0.0-rc3-snapshot.69ac1f4
Last verified with
Operating system
Windows
Operating system version
11
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