File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
test/SourceKit/CodeComplete
tools/SourceKit/lib/SwiftLang Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -183,3 +183,24 @@ func test6() {
183
183
// VOID_1_RAW-NEXT: key.context: source.codecompletion.context.thismodule,
184
184
// VOID_1_RAW-NEXT: key.num_bytes_to_erase: 0,
185
185
// VOID_1_RAW-NEXT: key.not_recommended: 1,
186
+
187
+
188
+
189
+ // RUN: %complete-test -tok=CASE_0 %s | FileCheck %s -check-prefix=CASE_0
190
+ func test7( ) {
191
+ struct CaseSensitiveCheck {
192
+ var member : Int = 0
193
+ }
194
+ let caseSensitiveCheck = CaseSensitiveCheck ( )
195
+ #^CASE_0 , caseSensitiveCheck, CaseSensitiveCheck^#
196
+ }
197
+ // CASE_0: Results for filterText: caseSensitiveCheck [
198
+ // CASE_0: caseSensitiveCheck
199
+ // CASE_0: CaseSensitiveCheck
200
+ // CASE_0: caseSensitiveCheck.
201
+ // CASE_0: ]
202
+ // CASE_0: Results for filterText: CaseSensitiveCheck [
203
+ // CASE_0: caseSensitiveCheck
204
+ // CASE_0: CaseSensitiveCheck
205
+ // CASE_0: CaseSensitiveCheck(
206
+ // CASE_0: ]
Original file line number Diff line number Diff line change @@ -586,8 +586,17 @@ void CodeCompletionOrganizer::Impl::addCompletionsWithFilter(
586
586
bool isExactMatch = match && completion->getName ().equals_lower (filterText);
587
587
588
588
if (isExactMatch) {
589
- if (!exactMatch)
589
+ if (!exactMatch) { // first match
590
590
exactMatch = completion;
591
+ } else if (completion->getName () != exactMatch->getName ()) {
592
+ if (completion->getName () == filterText && // first case-sensitive match
593
+ exactMatch->getName () != filterText)
594
+ exactMatch = completion;
595
+ else if (pattern.scoreCandidate (completion->getName ()) > // better match
596
+ pattern.scoreCandidate (exactMatch->getName ()))
597
+ exactMatch = completion;
598
+ }
599
+
591
600
match = (options.addInnerResults || options.addInnerOperators )
592
601
? options.includeExactMatch
593
602
: true ;
You can’t perform that action at this time.
0 commit comments