Skip to content

Commit c9bfe24

Browse files
committed
Fixed selection bug in InputTextField
1 parent 3231d72 commit c9bfe24

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Assets/Scripts/Core/Text/InputTextField.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ TextField.CharPosition GetCharPosition(Vector2 location)
818818
return v;
819819
}
820820
else if (firstInLine != -1)
821-
break;
821+
return v;
822822
}
823823

824824
return textField.charPositions[i - 1];

Assets/Scripts/Core/Text/TextField.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ public void GetLinesShape(int startLine, float startCharX, int endLine, float en
453453
{
454454
LineInfo line1 = _lines[startLine];
455455
LineInfo line2 = _lines[endLine];
456+
bool leftAlign = _textFormat.align == AlignType.Left;
456457
if (startLine == endLine)
457458
{
458459
Rect r = Rect.MinMaxRect(startCharX, line1.y, endCharX, line1.y + line1.height);
@@ -463,7 +464,7 @@ public void GetLinesShape(int startLine, float startCharX, int endLine, float en
463464
}
464465
else if (startLine == endLine - 1)
465466
{
466-
Rect r = Rect.MinMaxRect(startCharX, line1.y, GUTTER_X + line1.width, line1.y + line1.height);
467+
Rect r = Rect.MinMaxRect(startCharX, line1.y, leftAlign ? (GUTTER_X + line1.width) : _contentRect.xMax, line1.y + line1.height);
467468
if (clipped)
468469
resultRects.Add(ToolSet.Intersection(ref r, ref _contentRect));
469470
else
@@ -476,15 +477,15 @@ public void GetLinesShape(int startLine, float startCharX, int endLine, float en
476477
}
477478
else
478479
{
479-
Rect r = Rect.MinMaxRect(startCharX, line1.y, GUTTER_X + line1.width, line1.y + line1.height);
480+
Rect r = Rect.MinMaxRect(startCharX, line1.y, leftAlign ? (GUTTER_X + line1.width) : _contentRect.xMax, line1.y + line1.height);
480481
if (clipped)
481482
resultRects.Add(ToolSet.Intersection(ref r, ref _contentRect));
482483
else
483484
resultRects.Add(r);
484485
for (int i = startLine + 1; i < endLine; i++)
485486
{
486487
LineInfo line = _lines[i];
487-
r = Rect.MinMaxRect(GUTTER_X, r.yMax, GUTTER_X + line.width, line.y + line.height);
488+
r = Rect.MinMaxRect(GUTTER_X, r.yMax, leftAlign ? (GUTTER_X + line.width) : _contentRect.xMax, line.y + line.height);
488489
if (clipped)
489490
resultRects.Add(ToolSet.Intersection(ref r, ref _contentRect));
490491
else

0 commit comments

Comments
 (0)