public void SelectToPosition(Vector2 cursorPosition)
{
if (!this.m_MouseDragSelectsWholeWords)
{
this.cursorIndex = this.style.GetCursorStringIndex(this.position, this.m_Content, cursorPosition + this.scrollOffset);
}
else
{
int p = this.style.GetCursorStringIndex(this.position, this.m_Content, cursorPosition + this.scrollOffset);
if (this.m_DblClickSnap == DblClickSnapping.WORDS)
{
if (p < this.m_DblClickInitPos)
{
this.cursorIndex = this.FindEndOfClassification(p, -1);
this.selectIndex = this.FindEndOfClassification(this.m_DblClickInitPos, 1);
}
else
{
if (p >= this.text.Length)
{
p = this.text.Length - 1;
}
this.cursorIndex = this.FindEndOfClassification(p, 1);
this.selectIndex = this.FindEndOfClassification(this.m_DblClickInitPos - 1, -1);
}
}
else if (p < this.m_DblClickInitPos)
{
if (p > 0)
{
this.cursorIndex = this.text.LastIndexOf('\n', Mathf.Max(0, p - 2)) + 1;
}
else
{
this.cursorIndex = 0;
}
this.selectIndex = this.text.LastIndexOf('\n', this.m_DblClickInitPos);
}
else
{
if (p < this.text.Length)
{
this.cursorIndex = this.IndexOfEndOfLine(p);
}
else
{
this.cursorIndex = this.text.Length;
}
this.selectIndex = this.text.LastIndexOf('\n', Mathf.Max(0, this.m_DblClickInitPos - 2)) + 1;
}
}
}