Reset undo state when switching documents