From a4549db263ec0a979d9fa52f213f71e9f6137b94 Mon Sep 17 00:00:00 2001 From: Arrehn Date: Sat, 11 Dec 2010 19:51:34 -0500 Subject: [PATCH] FIRE-119 VWR-17751 Satomi Ahn - Script editors reported on wrong line Thanks Satomi! --- indra/llui/lltextbase.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 9adeddca99..ee31e0cd99 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2214,22 +2214,32 @@ bool LLTextBase::scrolledToEnd() return mScroller->isAtBottom(); } - -bool LLTextBase::setCursor(S32 row, S32 column) +bool LLTextBase::setCursor(S32 true_row, S32 column) { - if (0 <= row && row < (S32)mLineInfoList.size()) + if (0 <= true_row && true_row < (S32)mLineInfoList.size()) { - S32 doc_pos = mLineInfoList[row].mDocIndexStart; - column = llclamp(column, 0, mLineInfoList[row].mDocIndexEnd - mLineInfoList[row].mDocIndexStart - 1); - doc_pos += column; - updateCursorXPos(); - - return setCursorPos(doc_pos); + S32 row = true_row; + S32 doc_pos; + while ( row < (S32)mLineInfoList.size() && mLineInfoList[row].mLineNum < true_row ) row++; + while ( row < (S32)mLineInfoList.size() && mLineInfoList[row].mLineNum == true_row ) + { + S32 line_length = mLineInfoList[row].mDocIndexEnd - mLineInfoList[row].mDocIndexStart; + if ( column >= line_length) + { + column -= line_length; + row ++; + } + else + { + doc_pos = mLineInfoList[row].mDocIndexStart + column; + updateCursorXPos(); + return setCursorPos(doc_pos); + } + } } return false; } - bool LLTextBase::setCursorPos(S32 cursor_pos, bool keep_cursor_offset) { S32 new_cursor_pos = cursor_pos;