validPosition

If pos is a valid TextPosition for this document, it is returned (unchanged). Otherwise, a new TextPosition is returned, which is valid. The row is in the range :

0 .. lines.size

and column is in the range :

0 .. lines[row].length