mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Merge pull request #8641 from def-/pr-formatting
Also trim search strings in highlights
This commit is contained in:
commit
fddba0cc76
|
@ -1784,21 +1784,24 @@ bool CMenus::PrintHighlighted(const char *pName, F &&PrintFn)
|
|||
{
|
||||
const char *pStr = 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))))
|
||||
{
|
||||
str_copy(aFilterStrTrimmed, str_utf8_skip_whitespaces(aFilterStr));
|
||||
str_utf8_trim_right(aFilterStrTrimmed);
|
||||
// highlight the parts that matches
|
||||
const char *pFilteredStr;
|
||||
int FilterLen = str_length(aFilterStr);
|
||||
if(aFilterStr[0] == '"' && aFilterStr[FilterLen - 1] == '"')
|
||||
int FilterLen = str_length(aFilterStrTrimmed);
|
||||
if(aFilterStrTrimmed[0] == '"' && aFilterStrTrimmed[FilterLen - 1] == '"')
|
||||
{
|
||||
aFilterStr[FilterLen - 1] = '\0';
|
||||
pFilteredStr = str_comp(pName, &aFilterStr[1]) == 0 ? pName : nullptr;
|
||||
aFilterStrTrimmed[FilterLen - 1] = '\0';
|
||||
pFilteredStr = str_comp(pName, &aFilterStrTrimmed[1]) == 0 ? pName : nullptr;
|
||||
FilterLen -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *pFilteredStrEnd;
|
||||
pFilteredStr = str_utf8_find_nocase(pName, aFilterStr, &pFilteredStrEnd);
|
||||
pFilteredStr = str_utf8_find_nocase(pName, aFilterStrTrimmed, &pFilteredStrEnd);
|
||||
if(pFilteredStr != nullptr && pFilteredStrEnd != nullptr)
|
||||
FilterLen = pFilteredStrEnd - pFilteredStr;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue