[CodeCompletion] Swap the exact-match if one is a better case-sensitive match

Instead of just taking the first one, consider whether there is a better
result because of case-sensitivity.

rdar://problem/25994202
This commit is contained in:
Ben Langmuir
2016-05-02 10:57:17 -07:00
parent fd641cdbca
commit f1ba846c78
2 changed files with 31 additions and 1 deletions

View File

@@ -586,8 +586,17 @@ void CodeCompletionOrganizer::Impl::addCompletionsWithFilter(
bool isExactMatch = match && completion->getName().equals_lower(filterText);
if (isExactMatch) {
if (!exactMatch)
if (!exactMatch) { // first match
exactMatch = completion;
} else if (completion->getName() != exactMatch->getName()) {
if (completion->getName() == filterText && // first case-sensitive match
exactMatch->getName() != filterText)
exactMatch = completion;
else if (pattern.scoreCandidate(completion->getName()) > // better match
pattern.scoreCandidate(exactMatch->getName()))
exactMatch = completion;
}
match = (options.addInnerResults || options.addInnerOperators)
? options.includeExactMatch
: true;