Skip to content

Commit c7052fb

Browse files
committed
#139015 more optimizations
1 parent 354e2a5 commit c7052fb

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/vs/platform/extensionManagement/common/extensionGalleryService.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -565,18 +565,21 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
565565
async getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, arg1: any, arg2?: any): Promise<IGalleryExtension[]> {
566566
const options = CancellationToken.isCancellationToken(arg1) ? { targetPlatform: CURRENT_TARGET_PLATFORM } : arg1 as { targetPlatform: TargetPlatform, compatible?: boolean, queryAllVersions?: boolean };
567567
const token = CancellationToken.isCancellationToken(arg1) ? arg1 : arg2 as CancellationToken;
568-
const names: string[] = []; const ids: string[] = [], includePreRelease: (IExtensionIdentifier & { includePreRelease: boolean })[] = [], versions: (IExtensionIdentifier & { version: string })[] = [];
568+
const names: string[] = []; const ids: string[] = [], includePreReleases: (IExtensionIdentifier & { includePreRelease: boolean })[] = [], versions: (IExtensionIdentifier & { version: string })[] = [];
569+
let isQueryForReleaseVersionFromPreReleaseVersion = true;
569570
for (const extensionInfo of extensionInfos) {
570571
if (extensionInfo.uuid) {
571572
ids.push(extensionInfo.uuid);
572573
} else {
573574
names.push(extensionInfo.id);
574575
}
575576
// Set includePreRelease to true if version is set, because the version can be a pre-release version
576-
includePreRelease.push({ id: extensionInfo.id, uuid: extensionInfo.uuid, includePreRelease: !!(extensionInfo.version || extensionInfo.preRelease) });
577+
const includePreRelease = !!(extensionInfo.version || extensionInfo.preRelease);
578+
includePreReleases.push({ id: extensionInfo.id, uuid: extensionInfo.uuid, includePreRelease });
577579
if (extensionInfo.version) {
578580
versions.push({ id: extensionInfo.id, uuid: extensionInfo.uuid, version: extensionInfo.version });
579581
}
582+
isQueryForReleaseVersionFromPreReleaseVersion = isQueryForReleaseVersionFromPreReleaseVersion && (!!extensionInfo.hasPreRelease && !includePreRelease);
580583
}
581584

582585
if (!ids.length && !names.length) {
@@ -590,11 +593,11 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
590593
if (names.length) {
591594
query = query.withFilter(FilterType.ExtensionName, ...names);
592595
}
593-
if (options.queryAllVersions) {
596+
if (options.queryAllVersions || isQueryForReleaseVersionFromPreReleaseVersion /* Inlcude all versions if every requested extension is for release version and has pre-release version */) {
594597
query = query.withFlags(query.flags, Flags.IncludeVersions);
595598
}
596599

597-
const { extensions } = await this.queryGalleryExtensions(query, { targetPlatform: options.targetPlatform, includePreRelease, versions, compatible: !!options.compatible }, token);
600+
const { extensions } = await this.queryGalleryExtensions(query, { targetPlatform: options.targetPlatform, includePreRelease: includePreReleases, versions, compatible: !!options.compatible }, token);
598601
return extensions;
599602
}
600603

src/vs/platform/extensionManagement/common/extensionManagement.ts

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export interface IExtensionIdentifier {
235235
export interface IExtensionInfo extends IExtensionIdentifier {
236236
version?: string;
237237
preRelease?: boolean;
238+
hasPreRelease?: boolean;
238239
}
239240

240241
export interface IGalleryExtensionIdentifier extends IExtensionIdentifier {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ export class ExtensionEditor extends EditorPane {
484484
if (!preRelease && !extension.hasReleaseVersion) {
485485
return null;
486486
}
487-
return (await this.extensionGalleryService.query({ includePreRelease: preRelease, names: [extension.identifier.id] }, CancellationToken.None)).firstPage[0] || null;
487+
return (await this.extensionGalleryService.getExtensions([{ ...extension.identifier, preRelease, hasPreRelease: extension.hasPreReleaseVersion }], CancellationToken.None))[0] || null;
488488
}
489489

490490
private async render(extension: IExtension, template: IExtensionEditorTemplate, preserveFocus: boolean): Promise<void> {

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

-3
Original file line numberDiff line numberDiff line change
@@ -1247,9 +1247,6 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
12471247
} else {
12481248
await this.extensionManagementService.installFromGallery(gallery, installOptions);
12491249
}
1250-
const ids: string[] | undefined = extension.identifier.uuid ? [extension.identifier.uuid] : undefined;
1251-
const names: string[] | undefined = extension.identifier.uuid ? undefined : [extension.identifier.id];
1252-
this.queryGallery({ names, ids, pageSize: 1 }, CancellationToken.None);
12531250
return this.local.filter(local => areSameExtensions(local.identifier, gallery.identifier))[0];
12541251
} finally {
12551252
this.installing = this.installing.filter(e => e !== extension);

0 commit comments

Comments
 (0)