Fix bug that caused undo-tree to hang when undoing in region (bug#16377).