mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user