diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4ac7f5d783..749315c1c8 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -453,7 +453,12 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) return res; } - +// Returns first name, last name +BOOL LLCacheName::getFirstLastName(const LLUUID& id, std::string& first, std::string& last) +{ + return impl.getName(id, first, last); +} +// BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 2501354b62..b06c68d612 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -72,6 +72,7 @@ public: // If not available, copies the string "waiting". // Returns TRUE iff available. BOOL getFullName(const LLUUID& id, std::string& full_name); + BOOL getFirstLastName(const LLUUID& id, std::string& first, std::string& last); // returns first name, last name // Reverse lookup of UUID from name BOOL getUUID(const std::string& first, const std::string& last, LLUUID& id); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9ac8761488..98e130bdef 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -18763,7 +18763,7 @@ Change of this parameter will affect the layout of buttons in notification toast Value 1 - FSChatBarNamePrediction + FSChatbarNamePrediction Comment Toggles name prediction in nearby chat diff --git a/indra/newview/fsnearbychatcontrol.cpp b/indra/newview/fsnearbychatcontrol.cpp index d53b5ab436..b6371fb4ce 100644 --- a/indra/newview/fsnearbychatcontrol.cpp +++ b/indra/newview/fsnearbychatcontrol.cpp @@ -205,12 +205,11 @@ void FSNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) } } // FIRE-3192 - Predictive name completion, based on code by Satomi Ahn - static LLCachedControl sNameAutocomplete(gSavedSettings, "FSChatBarNamePrediction"); + static LLCachedControl sNameAutocomplete(gSavedSettings, "FSChatbarNamePrediction"); if (length > NAME_PREDICTION_MINIMUM_LENGTH && sNameAutocomplete && key < KEY_SPECIAL) { - std::string text = caller->getText(); S32 cur_pos = caller->getCursor(); - if (cur_pos && (text.at(cur_pos - 1) != ' ' || caller->hasSelection())) + if (raw_text[cur_pos - 1] != ' ' || caller->hasSelection()) { // Get a list of avatars within range std::vector avatar_ids; @@ -220,8 +219,8 @@ void FSNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) if (avatar_ids.empty()) return; // Nobody's in range! // Parse text for a pattern to search - std::string prefix = text.substr(0, cur_pos); // Text before search string - std::string suffix = text.substr(cur_pos, text.length() - cur_pos); // Text after search string + std::string prefix = wstring_to_utf8str(raw_text.substr(0, cur_pos)); // Text before search string + std::string suffix = wstring_to_utf8str(raw_text.substr(cur_pos, raw_text.length() - cur_pos)); // Text after search string U32 last_space = prefix.rfind(" "); std::string pattern = prefix.substr(last_space + 1, prefix.length() - last_space - 1); // Search pattern @@ -232,6 +231,7 @@ void FSNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) match_pattern = prefix.substr(last_space + 1, prefix.length() - last_space -1); prefix = prefix.substr(0, last_space + 1); + std::string match = pattern; LLStringUtil::toLower(pattern); std::string name; @@ -244,9 +244,11 @@ void FSNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) last_space = prefix.substr(0, prefix.length() - 2).rfind(" "); match_pattern = prefix.substr(last_space + 1, prefix.length() - last_space -1); prefix = prefix.substr(0, last_space + 1); + // prepare search pattern std::string full_pattern(match_pattern + pattern); LLStringUtil::toLower(full_pattern); + // Look for a match while (iter != avatar_ids.end() && !found) { @@ -265,12 +267,14 @@ void FSNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) if (found) { full_name = true; // ignore OnlyFirstName in case we want to disambiguate + prefix += match_pattern; } else if (!pattern.empty()) // if first search did not work, try matching with last word before cursor only { prefix += match_pattern; // first part of the pattern wasn't a pattern, so keep it in prefix LLStringUtil::toLower(pattern); iter = avatar_ids.begin(); + // Look for a match while (iter != avatar_ids.end() && !found) { @@ -289,22 +293,24 @@ void FSNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) // if we found something by either method, replace the pattern by the avatar name if (found) { - std::string name; - gCacheName->getFullName(*(iter - 1), name); + std::string first_name, last_name; + gCacheName->getFirstLastName(*(iter - 1), first_name, last_name); if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { - prefix += RlvStrings::getAnonym(name) + " "; + prefix += RlvStrings::getAnonym(first_name + " " + last_name) + " "; } else { - if (!full_name) + std::string rest_of_match; + if (full_name) { - U32 space = name.find(" "); - if (space != std::string::npos) - name = name.substr(0, space); + rest_of_match = /*first_name + " " +*/ last_name.substr(pattern.size()); } - - prefix += name + " "; + else + { + rest_of_match = first_name.substr(pattern.size()); + } + prefix += match + rest_of_match + " "; } caller->setText(prefix + suffix); caller->setSelection(prefix.length(), cur_pos); diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml index adabc08cce..b36b417c89 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml @@ -202,6 +202,15 @@ top_pad="5" height="16" width="400" /> + - - - @@ -763,7 +758,7 @@ height="18" control_name="FSNearbyChatbar" name="FSNearbyChatbar" - label="Add a chatbar in the Nearby Chat window"/> + label="Add a chat bar in the Nearby Chat window"/> @@ -1618,7 +1613,17 @@ name="spellcheck_showgui" commit_callback.function="Pref.SpellChecker" label="Spell Checking..." - width="150"> + width="160"> + +