From 3c8a7a9b8ea2805cbd4a3d092505816a87e8adb9 Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Fri, 25 Feb 2022 08:27:32 +0100 Subject: [PATCH] Fix EndOfLine navigation --- src/Avalonia.Controls/TextBox.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 99dae63392..229e6a6bba 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -1322,12 +1322,15 @@ namespace Avalonia.Controls var lineIndex = _presenter.TextLayout.GetLineIndexFromCharacterIndex(caretIndex, true); var textLine = textLines[lineIndex]; - if (caretIndex == textLine.TextRange.Start + textLine.TextRange.Length && lineIndex + 1 < textLines.Count) + if (caretIndex == textLine.TextRange.Start + textLine.TextRange.Length - textLine.NewLineLength && + lineIndex + 1 < textLines.Count) { textLine = textLines[++lineIndex]; } - _presenter.MoveCaretToTextPosition(textLine.TextRange.Start + textLine.TextRange.Length, true); + var textPosition = textLine.TextRange.Start + textLine.TextRange.Length - textLine.NewLineLength; + + _presenter.MoveCaretToTextPosition(textPosition, true); } }