mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
committed by
GitHub
parent
acba36e955
commit
d2316317da
@@ -719,7 +719,7 @@ export function registerChatActions() {
|
||||
|
||||
override async run(accessor: ServicesAccessor): Promise<void> {
|
||||
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
|
||||
extensionsWorkbenchService.openSearch(`@feature:${CopilotUsageExtensionFeatureId}`);
|
||||
extensionsWorkbenchService.openSearch(`@contribute:${CopilotUsageExtensionFeatureId}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1207,7 +1207,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
|
||||
this.registerExtensionAction({
|
||||
id: `extensions.sort.${id}`,
|
||||
title,
|
||||
precondition: ContextKeyExpr.and(precondition, ContextKeyExpr.regex(ExtensionsSearchValueContext.key, /^@feature:/).negate(), sortCapabilityContext),
|
||||
precondition: ContextKeyExpr.and(precondition, ContextKeyExpr.regex(ExtensionsSearchValueContext.key, /^@contribute:/).negate(), sortCapabilityContext),
|
||||
menu: [{
|
||||
id: extensionsSortSubMenu,
|
||||
when: ContextKeyExpr.and(ContextKeyExpr.or(CONTEXT_HAS_GALLERY, DefaultViewsContext), sortCapabilityContext),
|
||||
|
||||
@@ -400,12 +400,8 @@ export class ExtensionsListView extends AbstractExtensionsListView<IExtension> {
|
||||
extensions = this.filterRecentlyUpdatedExtensions(local, query, options);
|
||||
}
|
||||
|
||||
else if (/@feature:/i.test(query.value)) {
|
||||
const result = this.filterExtensionsByFeature(local, query);
|
||||
if (result) {
|
||||
extensions = result.extensions;
|
||||
description = result.description;
|
||||
}
|
||||
else if (/@contribute:/i.test(query.value)) {
|
||||
extensions = this.filterExtensionsByFeature(local, query);
|
||||
}
|
||||
|
||||
else if (includeBuiltin) {
|
||||
@@ -665,12 +661,12 @@ export class ExtensionsListView extends AbstractExtensionsListView<IExtension> {
|
||||
return this.sortExtensions(result, options);
|
||||
}
|
||||
|
||||
private filterExtensionsByFeature(local: IExtension[], query: Query): { extensions: IExtension[]; description: string } | undefined {
|
||||
const value = query.value.replace(/@feature:/g, '').trim();
|
||||
private filterExtensionsByFeature(local: IExtension[], query: Query): IExtension[] {
|
||||
const value = query.value.replace(/@contribute:/g, '').trim();
|
||||
const featureId = value.split(' ')[0];
|
||||
const feature = Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).getExtensionFeature(featureId);
|
||||
if (!feature) {
|
||||
return undefined;
|
||||
return [];
|
||||
}
|
||||
if (this.extensionsViewState) {
|
||||
this.extensionsViewState.filters.featureId = featureId;
|
||||
@@ -688,10 +684,7 @@ export class ExtensionsListView extends AbstractExtensionsListView<IExtension> {
|
||||
result.push([e, accessData?.accessTimes.length ?? 0]);
|
||||
}
|
||||
}
|
||||
return {
|
||||
extensions: result.sort(([, a], [, b]) => b - a).map(([e]) => e),
|
||||
description: localize('showingExtensionsForFeature', "Extensions using {0} in the last 30 days", feature.label)
|
||||
};
|
||||
return result.sort(([, a], [, b]) => b - a).map(([e]) => e);
|
||||
} finally {
|
||||
renderer?.dispose();
|
||||
}
|
||||
@@ -1262,7 +1255,7 @@ export class ExtensionsListView extends AbstractExtensionsListView<IExtension> {
|
||||
}
|
||||
|
||||
static isFeatureExtensionsQuery(query: string): boolean {
|
||||
return /@feature:/i.test(query);
|
||||
return /@contribute:/i.test(query);
|
||||
}
|
||||
|
||||
override focus(): void {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import { IExtensionGalleryManifest } from '../../../../platform/extensionManagement/common/extensionGalleryManifest.js';
|
||||
import { FilterType, SortBy } from '../../../../platform/extensionManagement/common/extensionManagement.js';
|
||||
import { EXTENSION_CATEGORIES } from '../../../../platform/extensions/common/extensions.js';
|
||||
import { Registry } from '../../../../platform/registry/common/platform.js';
|
||||
import { Extensions, IExtensionFeaturesRegistry } from '../../../services/extensionManagement/common/extensionFeatures.js';
|
||||
|
||||
export class Query {
|
||||
|
||||
@@ -15,7 +17,7 @@ export class Query {
|
||||
|
||||
static suggestions(query: string, galleryManifest: IExtensionGalleryManifest | null): string[] {
|
||||
|
||||
const commands = ['installed', 'updates', 'enabled', 'disabled', 'builtin'];
|
||||
const commands = ['installed', 'updates', 'enabled', 'disabled', 'builtin', 'contribute'];
|
||||
if (galleryManifest?.capabilities.extensionQuery?.filtering?.some(c => c.name === FilterType.Featured)) {
|
||||
commands.push('featured');
|
||||
}
|
||||
@@ -36,12 +38,18 @@ export class Query {
|
||||
}
|
||||
sortCommands.push('name', 'publishedDate', 'updateDate');
|
||||
|
||||
const contributeCommands = [];
|
||||
for (const feature of Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).getExtensionFeatures()) {
|
||||
contributeCommands.push(feature.id);
|
||||
}
|
||||
|
||||
const subcommands = {
|
||||
'sort': sortCommands,
|
||||
'category': isCategoriesEnabled ? EXTENSION_CATEGORIES.map(c => `"${c.toLowerCase()}"`) : [],
|
||||
'tag': [''],
|
||||
'ext': [''],
|
||||
'id': ['']
|
||||
'id': [''],
|
||||
'contribute': contributeCommands
|
||||
} as const;
|
||||
|
||||
const queryContains = (substr: string) => query.indexOf(substr) > -1;
|
||||
|
||||
Reference in New Issue
Block a user