Skip to content

Commit 34e1f76

Browse files
authored
1 parent ea61879 commit 34e1f76

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/vs/workbench/contrib/extensions/browser/extensionsViews.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,8 @@ export class ExtensionsListView extends ViewPane {
989989

990990
// Get All types of recommendations, trimmed to show a max of 8 at any given time
991991
private async getAllRecommendationsModel(options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
992-
const local = (await this.extensionsWorkbenchService.queryLocal(this.options.server)).map(e => e.identifier.id.toLowerCase());
992+
const localExtensions = await this.extensionsWorkbenchService.queryLocal(this.options.server);
993+
const localExtensionIds = localExtensions.map(e => e.identifier.id.toLowerCase());
993994

994995
const allRecommendations = distinct(
995996
flatten(await Promise.all([
@@ -998,10 +999,32 @@ export class ExtensionsListView extends ViewPane {
998999
this.extensionRecommendationsService.getImportantRecommendations(),
9991000
this.extensionRecommendationsService.getFileBasedRecommendations(),
10001001
this.extensionRecommendationsService.getOtherRecommendations()
1001-
])).filter(extensionId => !isString(extensionId) || !local.includes(extensionId.toLowerCase())));
1002+
])).filter(extensionId => {
1003+
if (isString(extensionId)) {
1004+
return !localExtensionIds.includes(extensionId.toLowerCase());
1005+
}
1006+
return !localExtensions.some(localExtension => localExtension.local && this.uriIdentityService.extUri.isEqual(localExtension.local.location, extensionId));
1007+
}));
10021008

10031009
const installableRecommendations = await this.getInstallableRecommendations(allRecommendations, { ...options, source: 'recommendations-all', sortBy: undefined }, token);
1004-
return new PagedModel(installableRecommendations.slice(0, 8));
1010+
1011+
const result: IExtension[] = [];
1012+
for (let i = 0; i < installableRecommendations.length && result.length < 8; i++) {
1013+
const recommendation = allRecommendations[i];
1014+
if (isString(recommendation)) {
1015+
const extension = installableRecommendations.find(extension => areSameExtensions(extension.identifier, { id: recommendation }));
1016+
if (extension) {
1017+
result.push(extension);
1018+
}
1019+
} else {
1020+
const extension = installableRecommendations.find(extension => extension.resourceExtension && this.uriIdentityService.extUri.isEqual(extension.resourceExtension.location, recommendation));
1021+
if (extension) {
1022+
result.push(extension);
1023+
}
1024+
}
1025+
}
1026+
1027+
return new PagedModel(result);
10051028
}
10061029

10071030
private async searchRecommendations(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {

0 commit comments

Comments
 (0)