And it is not like it gives you the option to browse up a folder and then save. But if you did that it might whinge about the folder name already being in use LOL
Not sure if I understand. If you manually save using file → save (or <ctrl>S) it's expected not to give you the option, it will just overwrite the the sketch files (.ino, .cpp, .h etc).
I forgot to ask, which exact version of the IDE? What type of install? ZIP, exe, msi?
Yes that's correct. It should just overwrite the sketch files (.ino, .cpp, .h etc). But it does not. It creates a new sub folder and saves all the files in that instead.
I found an old issue (for IDE 1.x (!); Why does Arduino save with folder in folder?) and it relates to network drives. Are you using a network drive? Or maybe OneDrive or similar)?
And I just tried it again on my complex sketch on E: drive and it didn't do it.
Is it possible the autosave is doing it from time to time somehow?
Occasionally the USB plug for E: drive works loose and E: drive goes off line with the sketch open in the IDE. And correct the plug and E: drive comes back online.
Is it possible that autosave then does something weird in that situation.
If it can't find the folder then the IDE should throw a file browse prompt.
I do not know but have doubts. You can switch autosave of if that would help with testing.
Press <ctrl><shift>P
Type auto save
Change the setting by clicking on it.
That might be a pointer; I suspect that if you loose the connection you will loose the file handle to the directory. Any chance of replacing the cable to see if it will solve the issue?
I tried to simulate with a memory stick. Removing the stick before the autosave kicks in results in below message.
and the sketch disappears from the IDE.
I have to re-open the sketch from the memory stick.
Observation:
No sketch inside sketch is created.
Trying to save the sketch with the memory stick still disconnected does not result in an error. Just in case it was saved elsewhere I scanned my hard drive (Documents folder) and could not find it.