I've run into this issue twice in the past couple of months.
First time it happened, I was modifying an existing sketch, and decided to save the modifications under a new name. I selected "Save as", and used whatever default directory was offered (it was somewhere in AppData). I then quit the IDE, only to discover a few days later that none of my modification were actually saved, and the second file was identical to my starting point. It was a small project, so I didn't dig deeper into what happened, and assumed I must have done something wrong.
After that, I started saving all of my sketches to Desktop (which is backed by OneDrive), so that I could be absolutely sure I knew where my code was.
Yesterday, I once again almost lost an hour of work (Autosave was on, and I was able to recover the file from the Temp directory that I learned about from Saving files is a crap shoot). I used "Save as", and put the new file on my Desktop. I thought it got saved properly, and quit the IDE, but when I came back to it some time later, the file did not have any of my recent changes. After recovering my work from the Temp directory and saving it in a separate text file just in case, I re-opened the IDE, and pasted the code.
That's when I noticed that even if I hit "Save", the circle in the corner of the file tab doesn't go away, so the file is not actually getting saved. I opened the file with Notepad, pasted my code, and tried to save, and Notepad told me that the file is read-only.
I am not sure whether it's some weird interaction with OneDrive, or some other bug, but it seems that "Save as" sometimes results in read-only files, and then the IDE does not show any sort of error when it fails to write to the file.