Don't snap cursor to 0 if position is invalid
In RTL text, it is very easy to land on an invalid position and thus the cursor keeps 'visually' jumping to the line start even though it's still standing at the clicked position.
Instead, just ensure the cursorPosition is within the text of layout.