logic: Fixed commands not in auto completions when symbols with same name exist

This commit is contained in:
Eberhard Graether
2018-11-05 17:10:11 +01:00
parent 9a8276d76e
commit 6d0fa311c1
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ bool SearchMatch::operator<(const SearchMatch& other) const
} }
} }
return false; return getSearchTypeName() < other.getSearchTypeName();
} }
bool SearchMatch::operator==(const SearchMatch& other) const bool SearchMatch::operator==(const SearchMatch& other) const
+7 -5
View File
@@ -627,8 +627,10 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::
utility::append(matches, getAutocompletionCommandMatches(query, acceptedNodeTypes)); utility::append(matches, getAutocompletionCommandMatches(query, acceptedNodeTypes));
// Rescore search matches to check if better score is achieved with higher indices // Rescore search matches to check if better score is achieved with higher indices
std::map<std::wstring, SearchMatch> matchesMap; std::vector<SearchMatch> rescoredMatches;
for (SearchMatch& match : matches) rescoredMatches.reserve(matches.size());
for (SearchMatch match : matches)
{ {
// rescore match // rescore match
if (!match.subtext.empty() && match.indices.size()) if (!match.subtext.empty() && match.indices.size())
@@ -640,15 +642,15 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::
match.indices = std::move(newResult.indices); match.indices = std::move(newResult.indices);
} }
matchesMap.emplace(match.name, match); rescoredMatches.emplace_back(match);
} }
// Score child symbol matches with same score as parent lower // Score child symbol matches with same score as parent lower
const SearchMatch* lastMatch = nullptr; const SearchMatch* lastMatch = nullptr;
std::set<SearchMatch> matchesSet; std::set<SearchMatch> matchesSet;
for (auto& p : matchesMap)
for (SearchMatch match : rescoredMatches)
{ {
SearchMatch& match = p.second;
if (lastMatch == nullptr || !utility::isPrefix(lastMatch->name, match.name)) if (lastMatch == nullptr || !utility::isPrefix(lastMatch->name, match.name))
{ {
lastMatch = &match; lastMatch = &match;