@@ -176,21 +176,14 @@ namespace ts {
176176 function matchTextChunk ( candidate : string , chunk : TextChunk , stringToWordSpans : Map < TextSpan [ ] > ) : PatternMatch | undefined {
177177 const index = indexOfIgnoringCase ( candidate , chunk . textLowerCase ) ;
178178 if ( index === 0 ) {
179- if ( chunk . text . length === candidate . length ) {
180- // a) Check if the part matches the candidate entirely, in an case insensitive or
181- // sensitive manner. If it does, return that there was an exact match.
182- return createPatternMatch ( PatternMatchKind . exact , /*isCaseSensitive:*/ candidate === chunk . text ) ;
183- }
184- else {
185- // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive
186- // manner. If it does, return that there was a prefix match.
187- return createPatternMatch ( PatternMatchKind . prefix , /*isCaseSensitive:*/ startsWith ( candidate , chunk . text ) ) ;
188- }
179+ // a) Check if the word is a prefix of the candidate, in a case insensitive or
180+ // sensitive manner. If it does, return that there was an exact match if the word and candidate are the same length, else a prefix match.
181+ return createPatternMatch ( chunk . text . length === candidate . length ? PatternMatchKind . exact : PatternMatchKind . prefix , /*isCaseSensitive:*/ startsWith ( candidate , chunk . text ) ) ;
189182 }
190183
191184 if ( chunk . isLowerCase ) {
192185 if ( index === - 1 ) return undefined ;
193- // c ) If the part is entirely lowercase, then check if it is contained anywhere in the
186+ // b ) If the part is entirely lowercase, then check if it is contained anywhere in the
194187 // candidate in a case insensitive manner. If so, return that there was a substring
195188 // match.
196189 //
@@ -203,7 +196,7 @@ namespace ts {
203196 return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ partStartsWith ( candidate , span , chunk . text , /*ignoreCase:*/ false ) ) ;
204197 }
205198 }
206- // d ) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries?
199+ // c ) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries?
207200 // We could check every character boundary start of the candidate for the pattern. However, that's
208201 // an m * n operation in the wost case. Instead, find the first instance of the pattern
209202 // substring, and see if it starts on a capital letter. It seems unlikely that the user will try to
@@ -214,13 +207,13 @@ namespace ts {
214207 }
215208 }
216209 else {
217- // e ) If the part was not entirely lowercase, then check if it is contained in the
210+ // d ) If the part was not entirely lowercase, then check if it is contained in the
218211 // candidate in a case *sensitive* manner. If so, return that there was a substring
219212 // match.
220213 if ( candidate . indexOf ( chunk . text ) > 0 ) {
221214 return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ true ) ;
222215 }
223- // f ) If the part was not entirely lowercase, then attempt a camel cased match as well.
216+ // e ) If the part was not entirely lowercase, then attempt a camel cased match as well.
224217 if ( chunk . characterSpans . length > 0 ) {
225218 const candidateParts = getWordSpans ( candidate , stringToWordSpans ) ;
226219 const isCaseSensitive = tryCamelCaseMatch ( candidate , candidateParts , chunk , /*ignoreCase:*/ false ) ? true
@@ -268,14 +261,11 @@ namespace ts {
268261 //
269262 // 3) Matching is as follows:
270263 //
271- // a) Check if the word matches the candidate entirely, in an case insensitive or
272- // sensitive manner. If it does, return that there was an exact match.
273- //
274- // b) Check if the word is a prefix of the candidate, in a case insensitive or
275- // sensitive manner. If it does, return that there was a prefix match.
264+ // a) Check if the word is a prefix of the candidate, in a case insensitive or
265+ // sensitive manner. If it does, return that there was an exact match if the word and candidate are the same length, else a prefix match.
276266 //
277267 // If the word is entirely lowercase:
278- // c ) Then check if it is contained anywhere in the
268+ // b ) Then check if it is contained anywhere in the
279269 // candidate in a case insensitive manner. If so, return that there was a substring
280270 // match.
281271 //
@@ -284,15 +274,15 @@ namespace ts {
284274 // types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with
285275 // 'a').
286276 //
287- // d ) The word is all lower case. Is it a case insensitive substring of the candidate starting
277+ // c ) The word is all lower case. Is it a case insensitive substring of the candidate starting
288278 // on a part boundary of the candidate?
289279 //
290280 // Else:
291- // e ) If the word was not entirely lowercase, then check if it is contained in the
281+ // d ) If the word was not entirely lowercase, then check if it is contained in the
292282 // candidate in a case *sensitive* manner. If so, return that there was a substring
293283 // match.
294284 //
295- // f ) If the word was not entirely lowercase, then attempt a camel cased match as
285+ // e ) If the word was not entirely lowercase, then attempt a camel cased match as
296286 // well.
297287 //
298288 // Only if all words have some sort of match is the pattern considered matched.
0 commit comments