quick access - clean up symbols matching
This commit is contained in:
parent
8d23203c65
commit
2b75f2d64e
3 changed files with 13 additions and 7 deletions
|
@ -268,11 +268,12 @@ export type FuzzyScore2 = [number /* score*/, IMatch[]];
|
|||
|
||||
const NO_SCORE2: FuzzyScore2 = [NO_MATCH, []];
|
||||
|
||||
export function scoreFuzzy2(target: string, query: IPreparedQuery, patternStart = 0, matchOffset = 0, skipMultiMatching = false): FuzzyScore2 {
|
||||
export function scoreFuzzy2(target: string, query: IPreparedQuery | IPreparedQueryPiece, patternStart = 0, matchOffset = 0): FuzzyScore2 {
|
||||
|
||||
// Score: multiple inputs (unless disabled)
|
||||
if (!skipMultiMatching && query.values && query.values.length > 1) {
|
||||
return doScoreFuzzy2Multiple(target, query.values, patternStart, matchOffset);
|
||||
// Score: multiple inputs
|
||||
const preparedQuery = query as IPreparedQuery;
|
||||
if (preparedQuery.values && preparedQuery.values.length > 1) {
|
||||
return doScoreFuzzy2Multiple(target, preparedQuery.values, patternStart, matchOffset);
|
||||
}
|
||||
|
||||
// Score: single input
|
||||
|
@ -796,9 +797,14 @@ export interface IPreparedQueryPiece {
|
|||
|
||||
export interface IPreparedQuery extends IPreparedQueryPiece {
|
||||
|
||||
// Split by spaces
|
||||
/**
|
||||
* Query split by spaces into pieces.
|
||||
*/
|
||||
values: IPreparedQueryPiece[] | undefined;
|
||||
|
||||
/**
|
||||
* Wether the query contains path separator(s) or not.
|
||||
*/
|
||||
containsPathSeparator: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
|
|||
// case we want to skip the container query altogether.
|
||||
let skipContainerQuery = false;
|
||||
if (symbolQuery !== query) {
|
||||
[symbolScore, symbolMatches] = scoreFuzzy2(symbolLabel, query, filterPos, symbolLabelIconOffset, true /* skip multi matching */);
|
||||
[symbolScore, symbolMatches] = scoreFuzzy2(symbolLabel, { ...query, values: undefined /* disable multi-query support */ }, filterPos, symbolLabelIconOffset);
|
||||
if (symbolScore) {
|
||||
skipContainerQuery = true; // since we consumed the query, skip any container matching
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ export class SymbolsQuickAccessProvider extends PickerQuickAccessProvider<ISymbo
|
|||
// can be a match on a markdown symbol "change log"). In that
|
||||
// case we want to skip the container query altogether.
|
||||
if (symbolQuery !== query) {
|
||||
[symbolScore, symbolMatches] = scoreFuzzy2(symbolLabel, query, 0, symbolLabelIconOffset, true /* skip multi matching */);
|
||||
[symbolScore, symbolMatches] = scoreFuzzy2(symbolLabel, { ...query, values: undefined /* disable multi-query support */ }, 0, symbolLabelIconOffset);
|
||||
if (symbolScore) {
|
||||
skipContainerQuery = true; // since we consumed the query, skip any container matching
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue