-
-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sketch deleted when location inside sketch folder selected as rename target #1882
Comments
@per1234 thanks for creating this issue on my behalf! I read through your analysis and I'm concerned that the proposed solution is a bandage on the underlying problem. The way I'm seeing the problem, if the main After looking through some of the source code, I found this in the sketch init service:
I believe a solution that would resolve the punishment for this action would be easier to implement. In addition, a function named "getSketches" implies no side-effects, but it's clearly doing some heavy lifting here. Ideally, this should simply do a check and pass the responsibility of resolution to the caller. I can take a look at this later if this solution sounds promising. I've got many years of experience working with Theia, so I'm happy to make a contribution, just let me know. Thanks again! |
IDE2 must disallow nested sketch destination location if the source sketch should be deleted, but the real problem is here: arduino-ide/arduino-ide-extension/src/browser/theia/workspace/workspace-commands.ts Line 150 in 79b6b7e
When renaming an ordinary, non-temp sketch, IDE2 must not wipe the source sketch as the operation is save-as. |
Do not wipe source sketch after save as if not a temp Closes #1882 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
Very cool that you are experienced with Theia @DerangedMind! Contributions are always welcome. In this specific case I would suggest you coordinate with @kittaakos before starting any serious work on a fix just so we avoid any chance of wasting your time due to duplicate efforts. I see @kittaakos already added a fix at bec6e92 |
Even though I appreciate the sentiment behind the dialog title, I don't think it is appropriate in this context. The user who triggers this dialog is already confused about the nature of Arduino sketches and is unlikely to be in the mindset to appreciate an obscure "Borges" reference. They may try to interpret it from a technical (vs. humorous) perspective and become even more confused. I would also drop the "this would go on forever" part. This is referencing a potential (it doesn't exist in Arduino IDE 2.x) defect in the application which would cause it to create an infinitely recursive subfolder structure until something breaks in the file/operating system. So this implies that the restriction is only a workaround for a defect instead of an intentional design. But as far as the idea of using a dialog to communicate the situation to the user, I'm fine with that.
I'm not sure about this. A rename operation is equivalent to a move, where the source is removed. That is the current behavior of the IDE's sketch rename feature. You are proposing changing it to a copy operation. |
We're on the same page 👍
I am open to any suggestions.
It's clearly a bug with IDE2. Check with IDE 1.x: save_as_is_not_move.mp4As a user of any software application, for me, save as does not mean moving and losing the original content but if you think IDE2 should behave differently, I can keep the current logic and let IDE2 wipe the original sketch content after save as. |
You are not performing a "rename" in that screencast. Try a rename in Arduino IDE 1.x and see what happens:
I agree, but this is not about a "Save As" operation, even if Arduino IDE 2.x is reusing the "Save As" infrastructure. The user is performing a "rename" operation, so they will expect the move behavior that is standard for any rename. |
You're the best. Thank you for the correction! It's not a bug. |
Describe the problem
The Arduino IDE editor toolbar contains a "context" menu accessed via the ●●● icon. This menu includes a "Rename" option. The behavior of the "Rename" option depends on which type of sketch file tab is selected in the editor:
.ino
file (the leftmost tab), the file and sketch folder are renamed🐛 If the user selects a location inside the current sketch folder when renaming the primary tab, the sketch may be deleted.
To reproduce
Foo
ⓘ This step is required due to No delete/rename menu actions from the editor toolbar if editor has no focus after app start #1847
The editor context menu will open.
The "Save sketch folder as..." dialog will open.
Foo
folder from the navigation panel of the dialog.Bar
🐛 Intermittently, the above procedure will cause the the
Bar
sketch to be deleted along with theFoo
parent folder.The other times it will not be deleted, but the logs show that the IDE still attempted the deletion:
The intermittent outcome seems to be dependent on the timing of whether the deletion of the
Foo
folder is completed before the IDE opens theFoo/Bar/Bar.ino
file. If the former, the sketch is deleted. If the latter, the deletion process fails due to the IDE creating a lock on it by having the sketch open.Expected behavior
There is no valid use case for this procedure. The user will only attempt the above procedure based on a misunderstanding of the nature on an Arduino sketch and how the IDE's "Rename" feature works when done on the primary sketch file. These users expect the outcome to be that the primary sketch file alone is renamed, resulting in this structure:
However, the IDE's "Rename" feature intentionally does not work this way due to the requirement that the primary
.ino
file match the sketch folder name.So the ideal behavior would be for Arduino IDE to:
If the above is not possible, the second best behavior would be to end with a structure like this:
This will not be the user's expected outcome, but the sketch is not deleted and remains valid.
Arduino IDE version
79b6b7e
Operating system
Windows
Operating system version
11
Additional context
I am also able to reproduce the fault using the tester build from #1833 (b9e9ae9). I found the fault was no longer intermittent, but sometimes has a different characteristic in that the sketch is deleted after existing the IDE. It seems the deletion is postponed when the IDE is not able to complete the process due to a lock:
Originally reported at https://forum.arduino.cc/t/arduino-ide-deleted-all-project-files-after-changing-from-ino-to-cpp/1088672
Issue checklist
The text was updated successfully, but these errors were encountered: