From 3f32f8e390c921f974e22260b9132f855b640758 Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Fri, 28 Jan 2022 13:32:34 +0100 Subject: [PATCH] Fix GetLineIndexFromCharacterIndex --- src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }