Skip to content

Commit 2b51e44

Browse files
authored
fix: providerName should be per result (microsoft#250079)
* Fix providerName usage * polish
1 parent 04ead50 commit 2b51e44

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,12 @@ export class LocalSearchProvider implements ISearchProvider {
128128
const topKeyMatchType = Math.max(...filterMatches.map(m => (m.matchType & SettingKeyMatchTypes)));
129129
// Always allow description matches as part of https://github.com/microsoft/vscode/issues/239936.
130130
const alwaysAllowedMatchTypes = SettingMatchType.DescriptionOrValueMatch | SettingMatchType.LanguageTagSettingMatch;
131-
const filteredMatches = filterMatches.filter(m => (m.matchType & topKeyMatchType) || (m.matchType & alwaysAllowedMatchTypes) || m.matchType === SettingMatchType.ExactMatch);
131+
const filteredMatches = filterMatches
132+
.filter(m => (m.matchType & topKeyMatchType) || (m.matchType & alwaysAllowedMatchTypes) || m.matchType === SettingMatchType.ExactMatch)
133+
.map(m => ({ ...m, providerName: 'local' }));
132134
return Promise.resolve({
133135
filterMatches: filteredMatches,
134-
exactMatch: filteredMatches.some(m => m.matchType === SettingMatchType.ExactMatch),
135-
providerName: 'local'
136+
exactMatch: filteredMatches.some(m => m.matchType === SettingMatchType.ExactMatch)
136137
});
137138
}
138139

@@ -422,11 +423,9 @@ class EmbeddingsSearchProvider implements IRemoteSearchProvider {
422423
this._recordProvider.updateModel(preferencesModel);
423424
this._aiSettingsSearchService.startSearch(this._filter, this._excludeSelectionStep, token);
424425

425-
const providerName = this._excludeSelectionStep ? 'embeddingsOnly' : 'embeddingsFull';
426426
return {
427427
filterMatches: await this.getEmbeddingsItems(token),
428-
exactMatch: false,
429-
providerName
428+
exactMatch: false
430429
};
431430
}
432431

@@ -438,6 +437,7 @@ class EmbeddingsSearchProvider implements IRemoteSearchProvider {
438437
return [];
439438
}
440439

440+
const providerName = this._excludeSelectionStep ? 'embeddingsOnly' : 'embeddingsFull';
441441
for (const settingKey of settings) {
442442
if (filterMatches.length === EmbeddingsSearchProvider.EMBEDDINGS_SETTINGS_SEARCH_MAX_PICKS) {
443443
break;
@@ -447,7 +447,8 @@ class EmbeddingsSearchProvider implements IRemoteSearchProvider {
447447
matches: [settingsRecord[settingKey].range],
448448
matchType: SettingMatchType.RemoteMatch,
449449
keyMatchScore: 0,
450-
score: 0 // the results are sorted upstream.
450+
score: 0, // the results are sorted upstream.
451+
providerName
451452
});
452453
}
453454

@@ -517,8 +518,7 @@ class TfIdfSearchProvider implements IRemoteSearchProvider {
517518

518519
return {
519520
filterMatches: await this.getTfIdfItems(token),
520-
exactMatch: false,
521-
providerName: 'tfIdf'
521+
exactMatch: false
522522
};
523523
}
524524

@@ -545,7 +545,8 @@ class TfIdfSearchProvider implements IRemoteSearchProvider {
545545
matches: [this._settingsRecord[pick].range],
546546
matchType: SettingMatchType.RemoteMatch,
547547
keyMatchScore: 0,
548-
score: info.score
548+
score: info.score,
549+
providerName: 'tfIdf'
549550
});
550551
}
551552

@@ -629,8 +630,7 @@ class AiSearchProvider implements IAiSearchProvider {
629630
const items = await this.getLLMRankedItems(token);
630631
return {
631632
filterMatches: items,
632-
exactMatch: false,
633-
providerName: 'llmRanked'
633+
exactMatch: false
634634
};
635635
}
636636

@@ -652,7 +652,8 @@ class AiSearchProvider implements IAiSearchProvider {
652652
matches: [settingsRecord[settingKey].range],
653653
matchType: SettingMatchType.RemoteMatch,
654654
keyMatchScore: 0,
655-
score: 0 // the results are sorted upstream.
655+
score: 0, // the results are sorted upstream.
656+
providerName: 'llmRanked'
656657
});
657658
}
658659

src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ export class SettingsEditor2 extends EditorPane {
12331233
type SettingsEditorModifiedSettingClassification = {
12341234
key: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The setting that is being modified.' };
12351235
groupId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the setting is from the local search or remote search provider, if applicable.' };
1236-
providerName: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The name of the remote search provider, if applicable.' };
1236+
providerName: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The name of the search provider, if applicable.' };
12371237
nlpIndex: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The index of the setting in the remote search provider results, if applicable.' };
12381238
displayIndex: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The index of the setting in the combined search results, if applicable.' };
12391239
showConfiguredOnly: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the user is in the modified view, which shows configured settings only.' };
@@ -1251,13 +1251,13 @@ export class SettingsEditor2 extends EditorPane {
12511251
displayIndex = props.searchResults.filterMatches.findIndex(m => m.setting.key === props.key);
12521252

12531253
if (this.searchResultModel) {
1254+
providerName = props.searchResults.filterMatches.find(m => m.setting.key === props.key)?.providerName;
12541255
const rawResults = this.searchResultModel.getRawResults();
12551256
if (rawResults[SearchResultIdx.Local] && displayIndex >= 0) {
12561257
const settingInLocalResults = rawResults[SearchResultIdx.Local].filterMatches.some(m => m.setting.key === props.key);
12571258
groupId = settingInLocalResults ? 'local' : 'remote';
12581259
}
12591260
if (rawResults[SearchResultIdx.Remote]) {
1260-
providerName = rawResults[SearchResultIdx.Remote].providerName;
12611261
const _nlpIndex = rawResults[SearchResultIdx.Remote].filterMatches.findIndex(m => m.setting.key === props.key);
12621262
nlpIndex = _nlpIndex >= 0 ? _nlpIndex : undefined;
12631263
}
@@ -1733,7 +1733,14 @@ export class SettingsEditor2 extends EditorPane {
17331733
for (const g of this.defaultSettingsEditorModel.settingsGroups.slice(1)) {
17341734
for (const sect of g.sections) {
17351735
for (const setting of sect.settings) {
1736-
fullResult.filterMatches.push({ setting, matches: [], matchType: SettingMatchType.None, keyMatchScore: 0, score: 0 });
1736+
fullResult.filterMatches.push({
1737+
setting,
1738+
matches: [],
1739+
matchType: SettingMatchType.None,
1740+
keyMatchScore: 0,
1741+
score: 0,
1742+
providerName: 'filterModel'
1743+
});
17371744
}
17381745
}
17391746
}

src/vs/workbench/services/preferences/common/preferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export interface ISearchResult {
111111
filterMatches: ISettingMatch[];
112112
exactMatch: boolean;
113113
metadata?: IFilterMetadata;
114-
providerName?: string;
115114
}
116115

117116
export interface ISearchResultGroup {
@@ -158,6 +157,7 @@ export interface ISettingMatch {
158157
matchType: SettingMatchType;
159158
keyMatchScore: number;
160159
score: number;
160+
providerName?: string;
161161
}
162162

163163
export interface IScoredResults {

0 commit comments

Comments
 (0)