In TextLine.HitTest() (TextLine.cs, around line 251), the check for paragraph separator (0x2029) has an operator precedence issue.
Current code:
if (lastRun.CodePoints.Length > 0 &&
(lastRun.CodePoints[lastRun.CodePoints.Length - 1] == '\n') ||
(lastRun.CodePoints[lastRun.CodePoints.Length - 1] == 0x2029)
)
Because && binds more tightly than ||, this is parsed as:
(Length > 0 && cp == '\n') || (cp == 0x2029)
The 0x2029 check bypasses the Length > 0 guard entirely. If CodePoints.Length is 0, the second part CodePoints[Length - 1] would still be evaluated, indexing at -1 and causing an IndexOutOfRangeException.
It should be:
if (lastRun.CodePoints.Length > 0 &&
(lastRun.CodePoints[lastRun.CodePoints.Length - 1] == '\n' ||
lastRun.CodePoints[lastRun.CodePoints.Length - 1] == 0x2029))
In
TextLine.HitTest()(TextLine.cs, around line 251), the check for paragraph separator (0x2029) has an operator precedence issue.Current code:
Because
&&binds more tightly than||, this is parsed as:The
0x2029check bypasses theLength > 0guard entirely. IfCodePoints.Lengthis 0, the second partCodePoints[Length - 1]would still be evaluated, indexing at-1and causing anIndexOutOfRangeException.It should be: