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

Check lang id while filtering #145756

Merged
merged 1 commit into from
Mar 23, 2022
Merged
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
15 changes: 12 additions & 3 deletions src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
import { ConfigurationScope, EditPresentationTypes } from 'vs/platform/configuration/common/configurationRegistry';
import { ILanguageService } from 'vs/editor/common/languages/language';

export const ONLINE_SERVICES_SETTING_TAG = 'usesOnlineServices';

Expand Down Expand Up @@ -147,7 +148,8 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
setting: ISetting,
parent: SettingsTreeGroupElement,
inspectResult: IInspectResult,
isWorkspaceTrusted: boolean
isWorkspaceTrusted: boolean,
private readonly languageService: ILanguageService
) {
super(sanitizeId(parent.id + '_' + setting.key));
this.setting = setting;
Expand Down Expand Up @@ -380,6 +382,11 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
return true;
}

if (!this.languageService.isRegisteredLanguageId(languageFilter)) {
rzhao271 marked this conversation as resolved.
Show resolved Hide resolved
// We're trying to filter by an invalid language.
return false;
}

// We have a language filter in the search widget at this point.
// We decide to show all language overridable settings to make the
// lang filter act more like a scope filter,
Expand Down Expand Up @@ -409,6 +416,7 @@ export class SettingsTreeModel {
protected _viewState: ISettingsEditorViewState,
private _isWorkspaceTrusted: boolean,
@IWorkbenchConfigurationService private readonly _configurationService: IWorkbenchConfigurationService,
@ILanguageService private readonly _languageService: ILanguageService
) {
}

Expand Down Expand Up @@ -506,7 +514,7 @@ export class SettingsTreeModel {

private createSettingsTreeSettingElement(setting: ISetting, parent: SettingsTreeGroupElement): SettingsTreeSettingElement {
const inspectResult = inspectSetting(setting.key, this._viewState.settingsTarget, this._viewState.languageFilter, this._configurationService);
const element = new SettingsTreeSettingElement(setting, parent, inspectResult, this._isWorkspaceTrusted);
const element = new SettingsTreeSettingElement(setting, parent, inspectResult, this._isWorkspaceTrusted, this._languageService);

const nameElements = this._treeElementsBySettingName.get(setting.key) || [];
nameElements.push(element);
Expand Down Expand Up @@ -749,8 +757,9 @@ export class SearchResultModel extends SettingsTreeModel {
isWorkspaceTrusted: boolean,
@IWorkbenchConfigurationService configurationService: IWorkbenchConfigurationService,
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@ILanguageService languageService: ILanguageService
) {
super(viewState, isWorkspaceTrusted, configurationService);
super(viewState, isWorkspaceTrusted, configurationService, languageService);
this.update({ id: 'searchResultModel', label: '' });
}

Expand Down