The desktop context will place itself in the middle of a selection's bounding box, if that middle also lies with the start and end rects. start/end rects are calculated as the union of rectangles which share a top/bottom border with the bounding rectangle.
| Simple | Complex |
The middle of bounding box isn't within the start/end rects, we place the context at the end-most edge of the end rect:
If the text contains subscript, that subscript gets its own rect which will have a lower bottom border than the rest of the line, and so will be consider the end rect on its own. This leads to a confusing context placement:
This is very much an edge case, but highlights a limitation in the selection rectangle API, which may be more prominent is some future use case.
One possible solution would be to merge in any rects which vertically overlap.



