When editing a file, you can normally undo/redo as much as you want. However, the moment you save (CMD+S), you can no longer undo anything. If I save the file but realize I made a mistake and want to undo it, that's not possible because the undo history is cleared upon file save. Please don't do that.
Saving a file clears undo history