@@ -176,21 +176,14 @@ namespace ts {
176
176
function matchTextChunk ( candidate : string , chunk : TextChunk , stringToWordSpans : Map < TextSpan [ ] > ) : PatternMatch | undefined {
177
177
const index = indexOfIgnoringCase ( candidate , chunk . textLowerCase ) ;
178
178
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 ) ) ;
189
182
}
190
183
191
184
if ( chunk . isLowerCase ) {
192
185
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
194
187
// candidate in a case insensitive manner. If so, return that there was a substring
195
188
// match.
196
189
//
@@ -203,7 +196,7 @@ namespace ts {
203
196
return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ partStartsWith ( candidate , span , chunk . text , /*ignoreCase:*/ false ) ) ;
204
197
}
205
198
}
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?
207
200
// We could check every character boundary start of the candidate for the pattern. However, that's
208
201
// an m * n operation in the wost case. Instead, find the first instance of the pattern
209
202
// 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 {
214
207
}
215
208
}
216
209
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
218
211
// candidate in a case *sensitive* manner. If so, return that there was a substring
219
212
// match.
220
213
if ( candidate . indexOf ( chunk . text ) > 0 ) {
221
214
return createPatternMatch ( PatternMatchKind . substring , /*isCaseSensitive:*/ true ) ;
222
215
}
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.
224
217
if ( chunk . characterSpans . length > 0 ) {
225
218
const candidateParts = getWordSpans ( candidate , stringToWordSpans ) ;
226
219
const isCaseSensitive = tryCamelCaseMatch ( candidate , candidateParts , chunk , /*ignoreCase:*/ false ) ? true
@@ -268,14 +261,11 @@ namespace ts {
268
261
//
269
262
// 3) Matching is as follows:
270
263
//
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.
276
266
//
277
267
// 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
279
269
// candidate in a case insensitive manner. If so, return that there was a substring
280
270
// match.
281
271
//
@@ -284,15 +274,15 @@ namespace ts {
284
274
// types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with
285
275
// 'a').
286
276
//
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
288
278
// on a part boundary of the candidate?
289
279
//
290
280
// 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
292
282
// candidate in a case *sensitive* manner. If so, return that there was a substring
293
283
// match.
294
284
//
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
296
286
// well.
297
287
//
298
288
// Only if all words have some sort of match is the pattern considered matched.
0 commit comments