auto mark when leaving edit mode