Skip to content

Commit 328d8e1

Browse files
make sure cache is different for quoted multi-piece queries
1 parent ecc7fda commit 328d8e1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/vs/base/common/fuzzyScorer.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,29 @@ export function scoreItemFuzzy<T>(item: T, query: IPreparedQuery, allowNonContig
381381

382382
const description = accessor.getItemDescription(item);
383383

384+
let piecesStr: string = '';
385+
let contiguousStr: string = '';
386+
if (Array.isArray(query.values)) {
387+
piecesStr += query.values.length;
388+
query.values.forEach(piece => {
389+
contiguousStr += piece.expectContiguousMatch;
390+
});
391+
} else {
392+
contiguousStr += query.expectContiguousMatch;
393+
}
394+
384395
// in order to speed up scoring, we cache the score with a unique hash based on:
385396
// - label
386397
// - description (if provided)
387398
// - query (normalized)
388399
// - number of query pieces (i.e. 'hello world' and 'helloworld' are different)
389-
// - whether fuzzy matching is enabled or not
400+
// - whether non-contiguous matching is enabled or not
401+
// - whether the query or pieces expect contiguous matches
390402
let cacheHash: string;
391403
if (description) {
392-
cacheHash = `${label}${description}${query.normalized}${Array.isArray(query.values) ? query.values.length : ''}${allowNonContiguousMatches}${query.expectContiguousMatch}`;
404+
cacheHash = `${label}${description}${query.normalized}${piecesStr}${allowNonContiguousMatches}${contiguousStr}`;
393405
} else {
394-
cacheHash = `${label}${query.normalized}${Array.isArray(query.values) ? query.values.length : ''}${allowNonContiguousMatches}${query.expectContiguousMatch}`;
406+
cacheHash = `${label}${query.normalized}${piecesStr}${allowNonContiguousMatches}${contiguousStr}`;
395407
}
396408

397409
const cached = cache[cacheHash];

0 commit comments

Comments
 (0)