Skip to content

Commit

Permalink
Check lang id while filtering (microsoft#145756)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 authored Mar 23, 2022
1 parent 1b2311e commit 12f99e0
Showing 1 changed file with 12 additions and 3 deletions.
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)) {
// 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

0 comments on commit 12f99e0

Please sign in to comment.