Reduce number of intersection checks when undoing highlighting

Intersection checks become very expensive when updating the highlight
on a large document. Intersections can only occur at the start and end of
a range, allowing only two of these to be necessary.