Arduino IDE 1.8.5 - understanding sketch 'saves'

Hi, I've just started with my UNO and the IDE application interface but fell into a big hole:

I'm used to MS Windows and intuitively how I expect applications to work. I loaded and ran a demo then modified the code, tested and uploaded it to UNO. Then I made some bad typo errors with cut and paste and thought I'd revert back as I'd not done a save.

First I tried just closing the application window, started it up and there was the corrupt code I had just left! I had previously tried 'Save As' but it didn't do what I expected. The net result seemed to be that despite not wanting the app to save my corrupt code, it did so (whether in the background, caching or not?) and I couldn't recover the previous working version. Most Windows drawing apps I use (like Eagle) maintain a save list each time the current file is altered or it's a selectable auto save option.

If somebody can understand my story, can they please explain the concepts behind the Arduino application for building and saving sketches? Until I understand what's going on I'm copying and pasting the edit screen into Notepad for backup and using the Archive sketch feature.

The Arduino IDE has the unexpected default behavior of saving the sketch whenever you do a Verify/compile or Upload. Luckily it's easy enough to fix that: File > Preferences > Save when verifying or uploading (uncheck) > OK.

I suggest that you to consider using Git version control at some point along your journey with Arduino. I wouldn't recommend it for a beginner since it will only make the learning curve steeper but for anyone who has gotten somewhat comfortable with Arduino it's an incredibly valuable tool.

Thanks, I'm still 'in the mud' so I will persevere with the basic tools, fall into holes like I've done and learn to try something different. I've already found my demo code seems to run each time but the app says my usb virtual com port isn't always connected and there's no serial output, yet I can read the board info .

May I suggest you expand and detail the last post....
Virtual serial port ?
Are you using a CLONE ?
What OS ?
What type of USB port ?