diff --git a/src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs b/src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs index 646204021b..0cc09e8259 100644 --- a/src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs +++ b/src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs @@ -394,12 +394,12 @@ namespace Avalonia.Media.TextFormatting { var textLine = TextLines[index]; - if (textLine.TextRange.End < charIndex) + if (textLine.TextRange.Start + textLine.TextRange.Length < charIndex) { continue; } - if (charIndex >= textLine.Start && charIndex <= textLine.TextRange.End) + if (charIndex >= textLine.Start && charIndex <= textLine.TextRange.Start + textLine.TextRange.Length) { return index; }