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

Support @builtin @disabled #235885

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
30 changes: 16 additions & 14 deletions src/vs/workbench/contrib/extensions/browser/extensionsViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,11 @@ export class ExtensionsListView extends ViewPane {
private async filterLocal(local: IExtension[], runningExtensions: readonly IExtensionDescription[], query: Query, options: IQueryOptions): Promise<{ extensions: IExtension[]; canIncludeInstalledExtensions: boolean; description?: string }> {
const value = query.value;
let extensions: IExtension[] = [];
let canIncludeInstalledExtensions = true;
let description: string | undefined;
const includeBuiltin = /@builtin/i.test(value);
const canIncludeInstalledExtensions = !includeBuiltin;

if (/@builtin/i.test(value)) {
extensions = this.filterBuiltinExtensions(local, query, options);
canIncludeInstalledExtensions = false;
}

else if (/@installed/i.test(value)) {
if (/@installed/i.test(value)) {
extensions = this.filterInstalledExtensions(local, runningExtensions, query, options);
}

Expand All @@ -462,7 +458,7 @@ export class ExtensionsListView extends ViewPane {
}

else if (/@enabled/i.test(value)) {
extensions = this.filterEnabledExtensions(local, runningExtensions, query, options);
extensions = this.filterEnabledExtensions(local, runningExtensions, query, options, includeBuiltin);
}

else if (/@workspaceUnsupported/i.test(value)) {
Expand All @@ -485,6 +481,10 @@ export class ExtensionsListView extends ViewPane {
}
}

else if (includeBuiltin) {
extensions = this.filterBuiltinExtensions(local, query, options);
}

return { extensions, canIncludeInstalledExtensions, description };
}

Expand Down Expand Up @@ -625,7 +625,7 @@ export class ExtensionsListView extends ViewPane {
private filterDisabledExtensions(local: IExtension[], runningExtensions: readonly IExtensionDescription[], query: Query, options: IQueryOptions): IExtension[] {
let { value, includedCategories, excludedCategories } = this.parseCategories(query.value);

value = value.replace(/@disabled/g, '').replace(/@sort:(\w+)(-\w*)?/g, '').trim().toLowerCase();
value = value.replace(/@disabled|@builtin/gi, '').replace(/@sort:(\w+)(-\w*)?/g, '').trim().toLowerCase();

const result = local
.sort((e1, e2) => e1.displayName.localeCompare(e2.displayName))
Expand All @@ -636,12 +636,14 @@ export class ExtensionsListView extends ViewPane {
return this.sortExtensions(result, options);
}

private filterEnabledExtensions(local: IExtension[], runningExtensions: readonly IExtensionDescription[], query: Query, options: IQueryOptions): IExtension[] {
private filterEnabledExtensions(local: IExtension[], runningExtensions: readonly IExtensionDescription[], query: Query, options: IQueryOptions, includeBuiltin: boolean): IExtension[] {
let { value, includedCategories, excludedCategories } = this.parseCategories(query.value);

value = value ? value.replace(/@enabled/g, '').replace(/@sort:(\w+)(-\w*)?/g, '').trim().toLowerCase() : '';
value = value ? value.replace(/@enabled|@builtin/gi, '').replace(/@sort:(\w+)(-\w*)?/g, '').trim().toLowerCase() : '';

local = local.filter(e => !e.isBuiltin);
if (!includeBuiltin) {
local = local.filter(e => !e.isBuiltin);
}
const result = local
.sort((e1, e2) => e1.displayName.localeCompare(e2.displayName))
.filter(e => runningExtensions.some(r => areSameExtensions({ id: r.identifier.value, uuid: r.uuid }, e.identifier))
Expand Down Expand Up @@ -1271,11 +1273,11 @@ export class ExtensionsListView extends ViewPane {
}

static isEnabledExtensionsQuery(query: string): boolean {
return /@enabled/i.test(query);
return /@enabled/i.test(query) && !/@builtin/i.test(query);
}

static isDisabledExtensionsQuery(query: string): boolean {
return /@disabled/i.test(query);
return /@disabled/i.test(query) && !/@builtin/i.test(query);
}

static isSearchDeprecatedExtensionsQuery(query: string): boolean {
Expand Down