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

Add suggestions for ext filter in the Settings editor search widget #148076

Merged
merged 1 commit into from
Apr 25, 2022
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
16 changes: 15 additions & 1 deletion src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import { Orientation, Sizing, SplitView } from 'vs/base/browser/ui/splitview/spl
import { Color } from 'vs/base/common/color';
import { ILanguageService } from 'vs/editor/common/languages/language';
import { SettingsSearchFilterDropdownMenuActionViewItem } from 'vs/workbench/contrib/preferences/browser/settingsSearchMenu';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionType } from 'vs/platform/extensions/common/extensions';

export const enum SettingsFocusContext {
Search,
Expand Down Expand Up @@ -202,6 +204,8 @@ export class SettingsEditor2 extends EditorPane {
private settingsTreeScrollTop = 0;
private dimension!: DOM.Dimension;

private installedExtensionIds: string[] = [];

constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchConfigurationService private readonly configurationService: IWorkbenchConfigurationService,
Expand All @@ -218,7 +222,8 @@ export class SettingsEditor2 extends EditorPane {
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
@IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService,
@IExtensionService private readonly extensionService: IExtensionService,
@ILanguageService private readonly languageService: ILanguageService
@ILanguageService private readonly languageService: ILanguageService,
@IExtensionManagementService extensionManagementService: IExtensionManagementService
) {
super(SettingsEditor2.ID, telemetryService, themeService, storageService);
this.delayedFilterLogging = new Delayer<void>(1000);
Expand Down Expand Up @@ -269,6 +274,10 @@ export class SettingsEditor2 extends EditorPane {
if (ENABLE_LANGUAGE_FILTER && !SettingsEditor2.SUGGESTIONS.includes(`@${LANGUAGE_SETTING_TAG}`)) {
SettingsEditor2.SUGGESTIONS.push(`@${LANGUAGE_SETTING_TAG}`);
}

extensionManagementService.getInstalled(ExtensionType.System).then(extensions => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a similar hack that PreferencesSearchService uses to "unwrap" the result from the async API.

this.installedExtensionIds = extensions.map(extension => extension.identifier.id);
});
}

override get minimumWidth(): number { return SettingsEditor2.EDITOR_MIN_WIDTH; }
Expand Down Expand Up @@ -538,6 +547,11 @@ export class SettingsEditor2 extends EditorPane {
return `@${LANGUAGE_SETTING_TAG}${languageId} `;
}).sort();
return sortedLanguages.filter(langFilter => !query.includes(langFilter));
} else if (queryParts[queryParts.length - 1].startsWith(`@${EXTENSION_SETTING_TAG}`)) {
const installedExtensionsTags = this.installedExtensionIds.map(extensionId => {
return `@${EXTENSION_SETTING_TAG}${extensionId} `;
}).sort();
return installedExtensionsTags.filter(extFilter => !query.includes(extFilter));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we can show the "display name" of the extension in the suggest widget as well? Maybe you can return a "detail" or "description" to show next to the ID

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into returning completion items for that case.

} else if (queryParts[queryParts.length - 1].startsWith('@')) {
return SettingsEditor2.SUGGESTIONS.filter(tag => !query.includes(tag)).map(tag => tag.endsWith(':') ? tag : tag + ' ');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class SettingsSearchFilterDropdownMenuActionViewItem extends DropdownMenu
localize('extSettingsSearch', "Extension ID..."),
localize('extSettingsSearchTooltip', "Add extension ID filter"),
`@${EXTENSION_SETTING_TAG}`,
false
true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes it so the completions list activates after the user selects the option from the funnel button.

),
this.createAction(
'featuresSettingsSearch',
Expand Down