fix for selections that overlap existing highlight

Reported and fixed by @csillag but never made it to master.