STORM-1855: Improve performance of pasting large blocks of text in the script editor

master
Oz Linden 2012-11-09 15:12:15 -05:00
parent bf6d167075
commit 07cc38e9cb
3 changed files with 20 additions and 9 deletions

View File

@ -496,6 +496,8 @@ Ima Mechanique
STORM-959
STORM-1175
STORM-1708
STORM-1855
VWR-20553
Imnotgoing Sideways
Inma Rau
Innula Zenovka
@ -1031,6 +1033,7 @@ Satanello Miami
Satomi Ahn
STORM-501
STORM-229
VWR-20553
VWR-24502
Scrim Pinion
Scrippy Scofield

View File

@ -1095,7 +1095,8 @@ void LLTextEditor::addChar(llwchar wc)
setCursorPos(mCursorPos + addChar( mCursorPos, wc ));
}
void LLTextEditor::addLineBreakChar()
void LLTextEditor::addLineBreakChar(BOOL group_together)
{
if( !getEnabled() )
{
@ -1113,7 +1114,7 @@ void LLTextEditor::addLineBreakChar()
LLStyleConstSP sp(new LLStyle(LLStyle::Params()));
LLTextSegmentPtr segment = new LLLineBreakTextSegment(sp, mCursorPos);
S32 pos = execute(new TextCmdAddChar(mCursorPos, FALSE, '\n', segment));
S32 pos = execute(new TextCmdAddChar(mCursorPos, group_together, '\n', segment));
setCursorPos(mCursorPos + pos);
}
@ -1436,21 +1437,28 @@ void LLTextEditor::pasteHelper(bool is_primary)
std::basic_string<llwchar>::size_type start = 0;
std::basic_string<llwchar>::size_type pos = clean_string.find('\n',start);
while(pos!=-1)
while((pos != -1) && (pos != clean_string.length() -1))
{
if(pos!=start)
{
std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,pos-start);
setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr()));
setCursorPos(mCursorPos + insert(mCursorPos, str, TRUE, LLTextSegmentPtr()));
}
addLineBreakChar();
addLineBreakChar(TRUE); // Add a line break and group with the next addition.
start = pos+1;
pos = clean_string.find('\n',start);
}
std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start);
setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr()));
if (pos != start)
{
std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start);
setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr()));
}
else
{
addLineBreakChar(FALSE); // Add a line break and end the grouping.
}
deselect();

View File

@ -239,7 +239,7 @@ protected:
// Undoable operations
void addChar(llwchar c); // at mCursorPos
S32 addChar(S32 pos, llwchar wc);
void addLineBreakChar();
void addLineBreakChar(BOOL group_together = FALSE);
S32 overwriteChar(S32 pos, llwchar wc);
void removeChar();
S32 removeChar(S32 pos);