The Arduino does not save when you compile/upload. IMO that is silly. I have lost several sketches when my PC crashed and I did not save.
I would not want it to as I often do some modifications to a sketch, only to then upload it and revert back to the old version.
Most IDE's have the undo buffer persist beyond saving. That is what I would normally do. Not sure if the Arduino IDE does that.