Fix ensureRangeInsideElem()

If the range was already contained but inside a text
node, the position inside the text node was lost.