This error has happened to me twice in quite a few hours of use over a number of days, so it's not a 100% repro.
I create a new class in my project, with a .h and .cpp, compiled and uploaded successfully. I switch to another source file. I see the editor do a full refresh on it's own, and switching back to the recent cpp, the file is completely empty and irretrievable.
This has happened to me twice now. I use chrome and firefox, and I think it's happened in both.
Could you please provide us with the URL of your file? Infos on your OS, Browser and Steps to reproduce will also be really helpful. When we have these infos we will look into it. Thanks
The steps are pretty much as I describe - it happens once in a blue moon, but enough to frighten me off. I think the last loss was Thursday 18th Jan 2018 around 10pm GMT.
I'm uploading to a Mega 2560 if that helps.
Thanks
Edit: It may be pertinent that I have LastPass extensions in both browsers.
Ok we traced it down and it looks like that cpp file was saved just once on Jan 18, 2018 11:39:38 PM GMT+0100 empty like it looks now.
Do you have the autosave option selected? You can check that on the properties panel.
Are you absolutely sure you saved your changes before closing the browser?
I do have "Save when verifying and uploading" and "autosave" ticked.
I definitely uploaded it to my arduino and got it running in the same browser session before it emptied. I remember being crestfallen that I'd lost it when it had been running ok.
The exact steps leading up to it after uploading were I switched to my .ino, headed to another browser to read some docs, and when I came back, the Editor tab full refreshed without my input. I built and got lots of errors, because my .cpp had been emptied.