logic: Fixed SearchMatch sorting not updated after rescoring

* also ignore template section in SearchMatch sorting
This commit is contained in:
Eberhard Graether
2017-02-09 23:54:21 +01:00
parent b423b41836
commit bfb997d35f
5 changed files with 53 additions and 22 deletions
+24 -1
View File
@@ -125,8 +125,19 @@ bool SearchMatch::operator<(const SearchMatch& other) const
otherStr = &other.name;
}
size_t size = getTextSizeForSorting(str);
size_t otherSize = other.getTextSizeForSorting(otherStr);
// text size
if (str->size() < otherStr->size())
if (size < otherSize)
{
return true;
}
else if (size > otherSize)
{
return false;
}
else if (str->size() < otherStr->size())
{
return true;
}
@@ -159,6 +170,18 @@ bool SearchMatch::operator<(const SearchMatch& other) const
return false;
}
size_t SearchMatch::getTextSizeForSorting(const std::string* str) const
{
// check if templated symbol and only use size up to template stuff
size_t pos = str->find('<');
if (pos != std::string::npos)
{
return pos;
}
return str->size();
}
bool SearchMatch::isValid() const
{
return searchType != SEARCH_NONE;
+2
View File
@@ -43,6 +43,8 @@ struct SearchMatch
bool operator<(const SearchMatch& other) const;
size_t getTextSizeForSorting(const std::string* str) const;
bool isValid() const;
void print(std::ostream& ostream) const;