diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts index 8037852103fa4..8ec573cce1e76 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts @@ -55,7 +55,7 @@ export class ConfigureLanguageBasedSettingsAction extends Action { if (pick) { const languageId = this.languageService.getLanguageIdByLanguageName(pick.label); if (typeof languageId === 'string') { - return this.preferencesService.openUserSettings({ jsonEditor: true, revealSetting: { key: `[${languageId}]`, edit: true } }); + return this.preferencesService.openLanguageSpecificSettings(languageId); } } return undefined; diff --git a/src/vs/workbench/services/preferences/browser/preferencesService.ts b/src/vs/workbench/services/preferences/browser/preferencesService.ts index cf784fb572492..eb5737fa9af6f 100644 --- a/src/vs/workbench/services/preferences/browser/preferencesService.ts +++ b/src/vs/workbench/services/preferences/browser/preferencesService.ts @@ -218,6 +218,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic return this.open(this.userSettingsResource, options); } + openLanguageSpecificSettings(languageId: string, options: IOpenSettingsOptions = {}): Promise { + if (this.shouldOpenJsonByDefault()) { + options.query = undefined; + options.revealSetting = { key: `[${languageId}]`, edit: true }; + } else { + options.query = `@lang:${languageId}${options.query ? ` ${options.query}` : ''}`; + } + options.target = options.target ?? ConfigurationTarget.USER_LOCAL; + + return this.open(this.userSettingsResource, options); + } + private open(settingsResource: URI, options: IOpenSettingsOptions): Promise { options = { ...options, diff --git a/src/vs/workbench/services/preferences/common/preferences.ts b/src/vs/workbench/services/preferences/common/preferences.ts index a60de6ae3c1cd..50588fe6d00b7 100644 --- a/src/vs/workbench/services/preferences/common/preferences.ts +++ b/src/vs/workbench/services/preferences/common/preferences.ts @@ -239,6 +239,7 @@ export interface IPreferencesService { openFolderSettings(options: IOpenSettingsOptions & { folderUri: IOpenSettingsOptions['folderUri'] }): Promise; openGlobalKeybindingSettings(textual: boolean, options?: IKeybindingsEditorOptions): Promise; openDefaultKeybindingsFile(): Promise; + openLanguageSpecificSettings(language: string, options?: IOpenSettingsOptions): Promise; getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): Promise; createSplitJsonEditorInput(configurationTarget: ConfigurationTarget, resource: URI): EditorInput;