mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Also trim search strings in highlights
This commit is contained in:
parent
a84a53c5fe
commit
1c2d7262d0
|
@ -1784,21 +1784,24 @@ bool CMenus::PrintHighlighted(const char *pName, F &&PrintFn)
|
||||||
{
|
{
|
||||||
const char *pStr = g_Config.m_BrFilterString;
|
const char *pStr = g_Config.m_BrFilterString;
|
||||||
char aFilterStr[sizeof(g_Config.m_BrFilterString)];
|
char aFilterStr[sizeof(g_Config.m_BrFilterString)];
|
||||||
|
char aFilterStrTrimmed[sizeof(g_Config.m_BrFilterString)];
|
||||||
while((pStr = str_next_token(pStr, IServerBrowser::SEARCH_EXCLUDE_TOKEN, aFilterStr, sizeof(aFilterStr))))
|
while((pStr = str_next_token(pStr, IServerBrowser::SEARCH_EXCLUDE_TOKEN, aFilterStr, sizeof(aFilterStr))))
|
||||||
{
|
{
|
||||||
|
str_copy(aFilterStrTrimmed, str_utf8_skip_whitespaces(aFilterStr));
|
||||||
|
str_utf8_trim_right(aFilterStrTrimmed);
|
||||||
// highlight the parts that matches
|
// highlight the parts that matches
|
||||||
const char *pFilteredStr;
|
const char *pFilteredStr;
|
||||||
int FilterLen = str_length(aFilterStr);
|
int FilterLen = str_length(aFilterStrTrimmed);
|
||||||
if(aFilterStr[0] == '"' && aFilterStr[FilterLen - 1] == '"')
|
if(aFilterStrTrimmed[0] == '"' && aFilterStrTrimmed[FilterLen - 1] == '"')
|
||||||
{
|
{
|
||||||
aFilterStr[FilterLen - 1] = '\0';
|
aFilterStrTrimmed[FilterLen - 1] = '\0';
|
||||||
pFilteredStr = str_comp(pName, &aFilterStr[1]) == 0 ? pName : nullptr;
|
pFilteredStr = str_comp(pName, &aFilterStrTrimmed[1]) == 0 ? pName : nullptr;
|
||||||
FilterLen -= 2;
|
FilterLen -= 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *pFilteredStrEnd;
|
const char *pFilteredStrEnd;
|
||||||
pFilteredStr = str_utf8_find_nocase(pName, aFilterStr, &pFilteredStrEnd);
|
pFilteredStr = str_utf8_find_nocase(pName, aFilterStrTrimmed, &pFilteredStrEnd);
|
||||||
if(pFilteredStr != nullptr && pFilteredStrEnd != nullptr)
|
if(pFilteredStr != nullptr && pFilteredStrEnd != nullptr)
|
||||||
FilterLen = pFilteredStrEnd - pFilteredStr;
|
FilterLen = pFilteredStrEnd - pFilteredStr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue