MAINT-3119 FIXED Return common chars for triggers that matches the prefix.
parent
74c7460846
commit
ec8bac9c26
|
|
@ -1339,6 +1339,7 @@ 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
|
||||
item_map_t::iterator it;
|
||||
for (it = mActive.begin(); it != mActive.end(); ++it)
|
||||
{
|
||||
|
|
@ -1346,7 +1347,24 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
|
|||
if (gesture)
|
||||
{
|
||||
const std::string& trigger = gesture->getTrigger();
|
||||
|
||||
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
|
||||
|
|
@ -1357,11 +1375,49 @@ BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)
|
|||
LLStringUtil::truncate(trigger_trunc, in_len);
|
||||
if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc))
|
||||
{
|
||||
*out_str = trigger;
|
||||
return TRUE;
|
||||
if (rest_of_match.compare("") == 0)
|
||||
{
|
||||
rest_of_match = trigger.substr(in_str.size());
|
||||
}
|
||||
std::string cur_rest_of_match = trigger.substr(in_str.size());
|
||||
buf = "";
|
||||
S32 i=0;
|
||||
|
||||
while (i<rest_of_match.length() && i<cur_rest_of_match.length())
|
||||
{
|
||||
if (rest_of_match[i]==cur_rest_of_match[i])
|
||||
{
|
||||
buf.push_back(rest_of_match[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i==0)
|
||||
{
|
||||
rest_of_match = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (rest_of_match.compare("") == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (buf.compare("") != 0)
|
||||
{
|
||||
rest_of_match = buf;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rest_of_match.compare("") != 0)
|
||||
{
|
||||
*out_str = in_str+rest_of_match;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue