diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index a258dcb57f..5e7399eecf 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -222,34 +222,47 @@ void LLLineEditor::autoCorrectText() S32 wordStart = 0; S32 wordEnd = mCursorPos-1; //llinfos <<"Checking Word, Cursor is at "< 0) && (' '!=text[wordEnd-1])) { wordEnd--; } + wordStart=wordEnd; + while ((wordEnd < (S32)text.length()) && (' '!=text[wordEnd] ) ) { wordEnd++; } - std::string lastTypedWord(std::string(text.begin(), - text.end()).substr(wordStart,wordEnd-wordStart)); - //llinfos << " The last typed word has been chosen, it is "<replaceWord(lastTypedWord)); + std::string strLastWord = std::string(text.begin(), text.end()); + std::string lastTypedWord = strLastWord.substr( wordStart, wordEnd-wordStart); + std::string correctedWord( LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord)); + if(correctedWord!=lastTypedWord) { - int nDiff = utf8str_to_utf16str( correctedWord ).size() - utf8str_to_utf16str( lastTypedWord ).size(); - std::string regText(mText); + LLWString strNew = utf8str_to_wstring( correctedWord ); + LLWString strOld = utf8str_to_wstring( lastTypedWord ); + int nDiff = strNew.size() - strOld.size(); + //int wordStart = regText.find(lastTypedWord); - regText.replace(wordStart,lastTypedWord.length(),correctedWord); - mText=regText; + text.replace(wordStart,lastTypedWord.length(),strNew); + mText = wstring_to_utf8str(text); mCursorPos+=nDiff; } }