Finish work on MAINT-3119 FIXED Return common chars for triggers that matches the prefix.
Makes the code cleaner too, upstream made this too messy.
This commit is contained in:
@@ -1358,7 +1358,8 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
|
||||
{
|
||||
S32 in_len = in_str.length();
|
||||
|
||||
//return whole trigger, if received text equals to it
|
||||
std::string rest_of_match = "";
|
||||
std::string buf = "";
|
||||
item_map_t::iterator it;
|
||||
for (it = mActive.begin(); it != mActive.end(); ++it)
|
||||
{
|
||||
@@ -1366,30 +1367,14 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
|
||||
if (gesture)
|
||||
{
|
||||
const std::string& trigger = gesture->getTrigger();
|
||||
//return whole trigger, if received text equals to it
|
||||
if (!LLStringUtil::compareInsensitive(in_str, trigger))
|
||||
{
|
||||
*out_str = trigger;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//return common chars, if more than one trigger matches the prefix
|
||||
std::string rest_of_match = "";
|
||||
std::string buf = "";
|
||||
for (it = mActive.begin(); it != mActive.end(); ++it)
|
||||
{
|
||||
LLMultiGesture* gesture = (*it).second;
|
||||
if (gesture)
|
||||
{
|
||||
const std::string& trigger = gesture->getTrigger();
|
||||
|
||||
if (in_len > (S32)trigger.length())
|
||||
{
|
||||
// too short, bail out
|
||||
continue;
|
||||
}
|
||||
|
||||
//return common chars, if more than one trigger matches the prefix
|
||||
std::string trigger_trunc = trigger;
|
||||
LLStringUtil::truncate(trigger_trunc, in_len);
|
||||
if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc))
|
||||
@@ -1430,6 +1415,13 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!rest_of_match.empty())
|
||||
{
|
||||
*out_str = in_str + rest_of_match;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user