Gently guessing prev. line caret pos on UP_ARROW

Fixes #3656
This commit is contained in:
Siarzhuk Zharski 2012-12-16 20:07:44 +01:00
parent 0d3bd614c7
commit 74f911be74

View File

@ -3505,8 +3505,17 @@ BTextView::_HandleArrowKey(uint32 inArrowKey, bool commandKeyDown)
else {
float height;
BPoint point = PointAt(fCaretOffset, &height);
point.y -= height;
fCaretOffset = OffsetAt(point);
// find the caret position on the previous
// line by gently stepping onto this line
for (int i = 1; i <= height; i++) {
point.y--;
int32 offset = OffsetAt(point);
if (offset < fCaretOffset || i == height) {
fCaretOffset = offset;
break;
}
}
if (shiftDown && fCaretOffset != lastClickOffset) {
if (fCaretOffset < fSelStart) {
// extend selection to the top