Fix rich text box snapping to be ignored at text end

#2964
This commit is contained in:
Wojtek Figat
2024-10-04 22:39:10 +02:00
parent c759b5fa24
commit 58e1396c15

View File

@@ -280,11 +280,16 @@ namespace FlaxEngine.GUI
GetNearestTextBlock(end, out TextBlock endTextBlock, !movingBack);
snappedStart = startTextBlock.Range.Contains(start) ? start : (movingBack ? startTextBlock.Range.EndIndex - 1 : startTextBlock.Range.StartIndex);
snappedEnd = endTextBlock.Range.Contains(end) ? end : (movingBack ? endTextBlock.Range.EndIndex - 1 : endTextBlock.Range.StartIndex);
snappedStart = movingBack ? Math.Min(start, snappedStart) : Math.Max(start, snappedStart);
snappedEnd = movingBack ? Math.Min(end, snappedEnd) : Math.Max(end, snappedEnd);
// Don't snap if selection is right in the end of the text
if (start == _text.Length)
snappedStart = _text.Length;
if (end == _text.Length)
snappedEnd = _text.Length;
}
base.SetSelection(snappedStart, snappedEnd, withScroll);