Fix selection on redo

This fixes the selection on redo by storing the to-redo
selection (i.e. current selection) on undo and vice versa.
This keeps the selection state consistent with the selection
whenever an undo/redo happens (since an undo can only be redone
and vice versa)

https://bugzilla.gnome.org/show_bug.cgi?id=672893