Harden undo / redo to external selection

Make sure that undo / redo can't accidentally introduce a selection by
calling out to 3rd party code.  If that does happen just clear the
selection and go back to normal mode.

closes #1479