Keep change history when switching between write and preview mode

My process is usually the following:

I make some changes in my article, then I go to preview mode to see whether the result is ok or not, then I switch back to writing mode, and undo it if it is not what I expected.

Unfortunately, I cannot do this at the moment, as the undo history is lost upon changing the mode.