Remove ordering by value and description

This commit is contained in:
Raymond Zhao 2021-11-18 08:40:08 -08:00
parent 200ef2057c
commit 6d07c4e616
No known key found for this signature in database
GPG key ID: D36E5FCE46B63B58
2 changed files with 7 additions and 14 deletions

View file

@ -468,7 +468,7 @@ export class SettingMatches {
const subSettingValueRanges: IRange[] = this.getRangesForWords(words, subSettingMatches.valueMatchingWords, [this.descriptionMatchingWords, this.keyMatchingWords, subSettingMatches.keyMatchingWords]);
result.push(...descriptionRanges, ...keyRanges, ...subSettingKeyRanges, ...subSettingValueRanges);
result.push(...subSettingMatches.matches);
this.refreshMatchType(descriptionRanges.length, keyRanges.length + subSettingKeyRanges.length, subSettingValueRanges.length);
this.refreshMatchType(keyRanges.length + subSettingKeyRanges.length);
this.matchType |= subSettingMatches.matchType;
}
}
@ -533,13 +533,13 @@ export class SettingMatches {
valueRanges = this.valuesMatcher(searchString, setting);
}
this.refreshMatchType(descriptionRanges.length, keyRanges.length, valueRanges.length);
this.refreshMatchType(keyRanges.length);
return [...descriptionRanges, ...keyRanges, ...valueRanges];
}
private checkForWholeWordMatchType(singleWordQuery: string, lineToSearch: string) {
// Trim excess ending characters off the query.
singleWordQuery = singleWordQuery.toLowerCase().trimEnd().replace(/[-\._]+$/, '');
singleWordQuery = singleWordQuery.toLowerCase().replace(/[\s-\._]+$/, '');
lineToSearch = lineToSearch.toLowerCase();
const singleWordRegex = new RegExp(`\\b${singleWordQuery}\\b`);
if (singleWordRegex.test(lineToSearch)) {
@ -547,16 +547,10 @@ export class SettingMatches {
}
}
private refreshMatchType(descriptionRangesLength: number, keyRangesLength: number, valueRangesLength: number) {
if (descriptionRangesLength) {
this.matchType |= SettingMatchType.DescriptionMatch;
}
private refreshMatchType(keyRangesLength: number) {
if (keyRangesLength) {
this.matchType |= SettingMatchType.KeyMatch;
}
if (valueRangesLength) {
this.matchType |= SettingMatchType.ValueMatch;
}
}
private getRangesForWords(words: string[], from: Map<string, IRange[]>, others: Map<string, IRange[]>[]): IRange[] {

View file

@ -118,13 +118,12 @@ export interface IFilterResult {
/**
* The ways a setting could match a query,
* sorted in increasing order of relevance.
* For now, ignore description and value matches.
*/
export enum SettingMatchType {
None = 0,
DescriptionMatch = 1 << 0,
ValueMatch = 1 << 1,
KeyMatch = 1 << 2,
WholeWordMatch = 1 << 3
WholeWordMatch = 1 << 0,
KeyMatch = 1 << 1
}
export interface ISettingMatch {