Fix completion hint for sub/superscripts (#52402)
Fix #52376
The completion hint starting offset was not computed considering the
case where the input and the completion do not share the same prefix,
which happens when completing into a subscript or a superscript. This
fixes that by iteratively going through the characters of the hint until
reaching that which marks the end of the input.