@@ -15,19 +15,10 @@ namespace ts {
1515 // better than substring matches which are better than CamelCase matches.
1616 kind : PatternMatchKind ;
1717
18- // If this was a camel case match, how strong the match is. Higher number means
19- // it was a better match.
20- camelCaseWeight ?: number ;
21-
2218 // If this was a match where all constituent parts of the candidate and search pattern
2319 // matched case sensitively or case insensitively. Case sensitive matches of the kind
2420 // are better matches than insensitive matches.
2521 isCaseSensitive : boolean ;
26-
27- // Whether or not this match occurred with the punctuation from the search pattern stripped
28- // out or not. Matches without the punctuation stripped are better than ones with punctuation
29- // stripped.
30- punctuationStripped : boolean ;
3122 }
3223
3324 // The pattern matcher maintains an internal cache of information as it is used. Therefore,
@@ -99,12 +90,10 @@ namespace ts {
9990 characterSpans : TextSpan [ ] ;
10091 }
10192
102- function createPatternMatch ( kind : PatternMatchKind , punctuationStripped : boolean , isCaseSensitive : boolean , camelCaseWeight ?: number ) : PatternMatch {
93+ function createPatternMatch ( kind : PatternMatchKind , isCaseSensitive : boolean ) : PatternMatch {
10394 return {
10495 kind,
105- punctuationStripped,
106- isCaseSensitive,
107- camelCaseWeight
96+ isCaseSensitive
10897 } ;
10998 }
11099
@@ -195,18 +184,18 @@ namespace ts {
195184 return spans ;
196185 }
197186
198- function matchTextChunk ( candidate : string , chunk : TextChunk , punctuationStripped : boolean ) : PatternMatch {
187+ function matchTextChunk ( candidate : string , chunk : TextChunk ) : PatternMatch {
199188 const index = indexOfIgnoringCase ( candidate , chunk . textLowerCase ) ;
200189 if ( index === 0 ) {
201190 if ( chunk . text . length === candidate . length ) {
202191 // a) Check if the part matches the candidate entirely, in an case insensitive or
203192 // sensitive manner. If it does, return that there was an exact match.
204- return createPatternMatch ( PatternMatchKind . exact , punctuationStripped , /*isCaseSensitive:*/ candidate === chunk . text ) ;
193+ return createPatternMatch ( PatternMatchKind . exact , /*isCaseSensitive:*/ candidate === chunk . text ) ;
205194 }
206195 else {
207196 // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive
208197 // manner. If it does, return that there was a prefix match.
209- return createPatternMatch ( PatternMatchKind . prefix , punctuationStripped , /*isCaseSensitive:*/ startsWith ( candidate , chunk . text ) ) ;
198+ return createPatternMatch ( PatternMatchKind . prefix , /*isCaseSensitive:*/ startsWith ( candidate , chunk . text ) ) ;
210199 }
211200 }
212201
@@ -223,8 +212,7 @@ namespace ts {
223212 const wordSpans = getWordSpans ( candidate ) ;
224213 for ( const span of wordSpans ) {
225214 if ( partStartsWith ( candidate , span , chunk . text , /*ignoreCase:*/ true ) ) {
226- return createPatternMatch ( PatternMatchKind . substring , punctuationStripped ,
227- /*isCaseSensitive:*/ partStartsWith ( candidate , span , chunk . text , /*ignoreCase:*/ false ) ) ;
215+ return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ partStartsWith ( candidate , span , chunk . text , /*ignoreCase:*/ false ) ) ;
228216 }
229217 }
230218 }
@@ -234,22 +222,18 @@ namespace ts {
234222 // candidate in a case *sensitive* manner. If so, return that there was a substring
235223 // match.
236224 if ( candidate . indexOf ( chunk . text ) > 0 ) {
237- return createPatternMatch ( PatternMatchKind . substring , punctuationStripped , /*isCaseSensitive:*/ true ) ;
225+ return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ true ) ;
238226 }
239227 }
240228
241229 if ( ! isLowercase ) {
242230 // e) If the part was not entirely lowercase, then attempt a camel cased match as well.
243231 if ( chunk . characterSpans . length > 0 ) {
244232 const candidateParts = getWordSpans ( candidate ) ;
245- let camelCaseWeight = tryCamelCaseMatch ( candidate , candidateParts , chunk , /*ignoreCase:*/ false ) ;
246- if ( camelCaseWeight !== undefined ) {
247- return createPatternMatch ( PatternMatchKind . camelCase , punctuationStripped , /*isCaseSensitive:*/ true , /*camelCaseWeight:*/ camelCaseWeight ) ;
248- }
249-
250- camelCaseWeight = tryCamelCaseMatch ( candidate , candidateParts , chunk , /*ignoreCase:*/ true ) ;
251- if ( camelCaseWeight !== undefined ) {
252- return createPatternMatch ( PatternMatchKind . camelCase , punctuationStripped , /*isCaseSensitive:*/ false , /*camelCaseWeight:*/ camelCaseWeight ) ;
233+ const isCaseSensitive = tryCamelCaseMatch ( candidate , candidateParts , chunk , /*ignoreCase:*/ false ) ? true
234+ : tryCamelCaseMatch ( candidate , candidateParts , chunk , /*ignoreCase:*/ true ) ? false : undefined ;
235+ if ( isCaseSensitive !== undefined ) {
236+ return createPatternMatch ( PatternMatchKind . camelCase , isCaseSensitive ) ;
253237 }
254238 }
255239 }
@@ -264,7 +248,7 @@ namespace ts {
264248 // (Pattern: fogbar, Candidate: quuxfogbarFogBar).
265249 if ( chunk . text . length < candidate . length ) {
266250 if ( index > 0 && isUpperCaseLetter ( candidate . charCodeAt ( index ) ) ) {
267- return createPatternMatch ( PatternMatchKind . substring , punctuationStripped , /*isCaseSensitive:*/ false ) ;
251+ return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ false ) ;
268252 }
269253 }
270254 }
@@ -292,7 +276,7 @@ namespace ts {
292276 // Note: if the segment contains a space or an asterisk then we must assume that it's a
293277 // multi-word segment.
294278 if ( ! containsSpaceOrAsterisk ( segment . totalTextChunk . text ) ) {
295- const match = matchTextChunk ( candidate , segment . totalTextChunk , /*punctuationStripped:*/ false ) ;
279+ const match = matchTextChunk ( candidate , segment . totalTextChunk ) ;
296280 if ( match ) {
297281 return [ match ] ;
298282 }
@@ -340,7 +324,7 @@ namespace ts {
340324
341325 for ( const subWordTextChunk of subWordTextChunks ) {
342326 // Try to match the candidate with this word
343- const result = matchTextChunk ( candidate , subWordTextChunk , /*punctuationStripped:*/ true ) ;
327+ const result = matchTextChunk ( candidate , subWordTextChunk ) ;
344328 if ( ! result ) {
345329 return undefined ;
346330 }
@@ -383,7 +367,7 @@ namespace ts {
383367 return true ;
384368 }
385369
386- function tryCamelCaseMatch ( candidate : string , candidateParts : TextSpan [ ] , chunk : TextChunk , ignoreCase : boolean ) : number {
370+ function tryCamelCaseMatch ( candidate : string , candidateParts : TextSpan [ ] , chunk : TextChunk , ignoreCase : boolean ) : boolean {
387371 const chunkCharacterSpans = chunk . characterSpans ;
388372
389373 // Note: we may have more pattern parts than candidate parts. This is because multiple
@@ -399,24 +383,11 @@ namespace ts {
399383 while ( true ) {
400384 // Let's consider our termination cases
401385 if ( currentChunkSpan === chunkCharacterSpans . length ) {
402- // We did match! We shall assign a weight to this
403- let weight = 0 ;
404-
405- // Was this contiguous?
406- if ( contiguous ) {
407- weight += 1 ;
408- }
409-
410- // Did we start at the beginning of the candidate?
411- if ( firstMatch === 0 ) {
412- weight += 2 ;
413- }
414-
415- return weight ;
386+ return true ;
416387 }
417388 else if ( currentCandidate === candidateParts . length ) {
418389 // No match, since we still have more of the pattern to hit
419- return undefined ;
390+ return false ;
420391 }
421392
422393 let candidatePart = candidateParts [ currentCandidate ] ;
0 commit comments