Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use content pattern instead of remotes #177186

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/base/common/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export interface IConfigBasedExtensionTip {
configScheme?: string;
recommendations: IStringDictionary<{
name: string;
remotes?: string[];
contentPattern?: string;
important?: boolean;
isExtensionPack?: boolean;
whenNotInstalled?: string[];
Expand Down
32 changes: 9 additions & 23 deletions src/vs/platform/extensionManagement/common/extensionTipsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { IConfigBasedExtensionTip as IRawConfigBasedExtensionTip } from 'vs/base/common/product';
import { joinPath } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { getDomainsOfRemotes } from 'vs/platform/extensionManagement/common/configRemotes';
import { IConfigBasedExtensionTip, IExecutableBasedExtensionTip, IExtensionManagementService, IExtensionTipsService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IFileService } from 'vs/platform/files/common/files';
import { IProductService } from 'vs/platform/product/common/productService';
Expand Down Expand Up @@ -62,21 +61,15 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
continue;
}
try {
const content = await this.fileService.readFile(joinPath(folder, configPath));
const recommendationByRemote: Map<string, IConfigBasedExtensionTip> = new Map<string, IConfigBasedExtensionTip>();
Object.entries(tip.recommendations).forEach(([key, value]) => {
if (isNonEmptyArray(value.remotes)) {
for (const remote of value.remotes) {
recommendationByRemote.set(remote, {
extensionId: key,
extensionName: value.name,
configName: tip.configName,
important: !!value.important,
isExtensionPack: !!value.isExtensionPack,
whenNotInstalled: value.whenNotInstalled
});
}
} else {
let content: string | undefined;
const getContent = async () => {
if (content === undefined) {
content = (await this.fileService.readFile(joinPath(folder, configPath))).value.toString();
}
return content;
};
for (const [key, value] of Object.entries(tip.recommendations)) {
if (!value.contentPattern || new RegExp(value.contentPattern, 'mig').test(await getContent())) {
result.push({
extensionId: key,
extensionName: value.name,
Expand All @@ -86,13 +79,6 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
whenNotInstalled: value.whenNotInstalled
});
}
});
const domains = getDomainsOfRemotes(content.value.toString(), [...recommendationByRemote.keys()]);
for (const domain of domains) {
const remote = recommendationByRemote.get(domain);
if (remote) {
result.push(remote);
}
}
} catch (error) { /* Ignore */ }
}
Expand Down