diff --git a/packages/vsx-registry/src/browser/vsx-extensions-model.ts b/packages/vsx-registry/src/browser/vsx-extensions-model.ts index b011688b4849b..4c031522aae4a 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-model.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-model.ts @@ -21,7 +21,7 @@ import * as sanitize from 'sanitize-html'; import { Emitter } from '@theia/core/lib/common/event'; import { CancellationToken, CancellationTokenSource } from '@theia/core/lib/common/cancellation'; import { VSXRegistryAPI, VSXResponseError } from '../common/vsx-registry-api'; -import { VSXSearchParam } from '../common/vsx-registry-types'; +import { VSXExtensionRaw, VSXSearchParam } from '../common/vsx-registry-types'; import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin'; import { VSXExtension, VSXExtensionFactory } from './vsx-extension'; import { ProgressService } from '@theia/core/lib/common/progress-service'; @@ -217,7 +217,7 @@ export class VSXExtensionsModel { protected async refresh(id: string): Promise { try { - const data = await this.api.getLatestCompatibleExtensionVersion(id); + const data = await this.getExtensionData(id); if (!data) { return; } @@ -249,6 +249,24 @@ export class VSXExtensionsModel { return undefined; } + protected isBuiltin(id: string): boolean { + return this.getExtension(id)?.builtin === true; + } + + /** + * Get the extension data if it exists. + * - If the extension is a builtin, no compatibility check is performed. + * - If the extension is not a builtin, the latest compatible version should be fetched. + * @param id the extension id. + * + * @returns the extension data if it exists. + */ + protected async getExtensionData(id: string): Promise { + return this.isBuiltin(id) + ? this.api.getExtension(id) + : this.api.getLatestCompatibleExtensionVersion(id); + } + /** * Compare two extensions based on their display name, and publisher if applicable. * @param a the first extension id for comparison. diff --git a/packages/vsx-registry/src/common/vsx-registry-api.ts b/packages/vsx-registry/src/common/vsx-registry-api.ts index 28ba7878b9992..7158d5e5df880 100644 --- a/packages/vsx-registry/src/common/vsx-registry-api.ts +++ b/packages/vsx-registry/src/common/vsx-registry-api.ts @@ -41,11 +41,6 @@ export namespace VSXResponseError { } } -/** - * Namespace reserved for vscode builtin extensions. - */ -const VSCODE_NAMESPACE = 'vscode'; - @injectable() export class VSXRegistryAPI { @@ -145,10 +140,7 @@ export class VSXRegistryAPI { const extensions = await this.getAllVersions(id); for (let i = 0; i < extensions.length; i++) { const extension: VSXExtensionRaw = extensions[i]; - // Skip vscode builtin extensions. - if (extension.namespace === VSCODE_NAMESPACE) { - return extension; - } else if (extension.engines && this.isEngineSupported(extension.engines.vscode)) { + if (extension.engines && this.isEngineSupported(extension.engines.vscode)) { return extension; } }