From f944b405c4e752074d3d864ee7072eb1e0f7b6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 21 Jan 2014 23:02:19 +0100 Subject: [PATCH] TextEditor: Comment on up/down behavior for first/last line. --- src/apps/haiku-depot/textview/TextEditor.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/apps/haiku-depot/textview/TextEditor.cpp b/src/apps/haiku-depot/textview/TextEditor.cpp index f1ce5a331c..9fb78ace97 100644 --- a/src/apps/haiku-depot/textview/TextEditor.cpp +++ b/src/apps/haiku-depot/textview/TextEditor.cpp @@ -369,10 +369,17 @@ void TextEditor::_MoveToLine(int32 lineIndex, bool select) { if (lineIndex < 0) { + // Move to beginning of line instead. Most editors do. Some only when + // selecting. Note that we are not updating the horizontal anchor here, + // even though the horizontal caret position changes. Most editors + // return to the previous horizonal offset when moving back down from + // the beginning of the line. _SetCaretOffset(0, false, select, true); return; } if (lineIndex >= fLayout->CountLines()) { + // Move to end of line instead, see above for why we do not update the + // horizontal anchor. _SetCaretOffset(fDocument->Length(), false, select, true); return; }