Linear search, and it's called from a loop on `mergedRegions`. Quadratic complexity is really bad in an editor, and I think this could be a hot path. I'd rather build a temporary and efficient intermediate data structure: build the whole list once and do binary search on it (can we assume regions are in textual order?).

I wonder if we can have a sort of map instead, but I'd be happy with binary search too.