diff --git a/search/search_query.cpp b/search/search_query.cpp index 63e2f096b8..28f4c9f7b2 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -888,14 +888,16 @@ void Query::GetSuggestion(string const & name, string & suggest) const auto const & token = tokens[i]; if (find(m_tokens.begin(), m_tokens.end(), token) != m_tokens.end()) tokensMatched[i] = true; - else if (token.size() >= m_prefix.size() && StartsWith(token, m_prefix)) + else if (StartsWith(token, m_prefix)) { prefixMatched = true; fullPrefixMatched = token.size() == m_prefix.size(); } } - // Name doesn't match prefix - do nothing. + // When |name| does not match prefix or when prefix equals to some + // token of the |name| (for example, when user entered "Moscow" + // without space at the end), we should not suggest anything. if (!prefixMatched || fullPrefixMatched) return; @@ -906,8 +908,8 @@ void Query::GetSuggestion(string const & name, string & suggest) const { if (tokensMatched[i]) continue; - suggest += strings::ToUtf8(tokens[i]); - suggest += " "; + suggest.append(strings::ToUtf8(tokens[i])); + suggest.push_back(' '); } } diff --git a/search/v2/geocoder.cpp b/search/v2/geocoder.cpp index 05e9aab913..4249f9e181 100644 --- a/search/v2/geocoder.cpp +++ b/search/v2/geocoder.cpp @@ -889,11 +889,6 @@ void Geocoder::MatchRegions(RegionType type) } } -void Geocoder::EmitResult(MwmSet::MwmId const & mwmId, uint32_t featureId) -{ - m_results->emplace_back(mwmId, featureId); -} - void Geocoder::MatchCities() { // Localities are ordered my (m_startToken, m_endToken) pairs. @@ -1223,6 +1218,11 @@ void Geocoder::FindPaths() }); } +void Geocoder::EmitResult(MwmSet::MwmId const & mwmId, uint32_t featureId) +{ + m_results->emplace_back(mwmId, featureId); +} + void Geocoder::MatchUnclassified(size_t curToken) { ASSERT(m_layers.empty(), ());