Only undo when there's something to undo.