From aefb3351f46c05574b457416b5a700b0622e9038 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 28 Mar 2022 11:03:02 +0530 Subject: [PATCH 1/4] Fix #146161 --- .../workbench/contrib/preferences/browser/preferencesActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts index 8037852103fa4..fb5cd63ac1f27 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.openUserSettings({ query: `@lang:${languageId}` }); } } return undefined; From d8847c8e6adcbb359470ed1cdd41774b6ed927c3 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 28 Mar 2022 11:06:28 +0530 Subject: [PATCH 2/4] #146161 - consider settings editor config --- .../contrib/preferences/browser/preferencesActions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts index fb5cd63ac1f27..73f5b9268b173 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts @@ -11,6 +11,7 @@ import { ILanguageService } from 'vs/editor/common/languages/language'; import * as nls from 'vs/nls'; import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export class ConfigureLanguageBasedSettingsAction extends Action { @@ -23,7 +24,8 @@ export class ConfigureLanguageBasedSettingsAction extends Action { @IModelService private readonly modelService: IModelService, @ILanguageService private readonly languageService: ILanguageService, @IQuickInputService private readonly quickInputService: IQuickInputService, - @IPreferencesService private readonly preferencesService: IPreferencesService + @IPreferencesService private readonly preferencesService: IPreferencesService, + @IConfigurationService private readonly configurationService: IConfigurationService, ) { super(id, label); } @@ -55,7 +57,11 @@ export class ConfigureLanguageBasedSettingsAction extends Action { if (pick) { const languageId = this.languageService.getLanguageIdByLanguageName(pick.label); if (typeof languageId === 'string') { - return this.preferencesService.openUserSettings({ query: `@lang:${languageId}` }); + if (this.configurationService.getValue('workbench.settings.editor') === 'json') { + return this.preferencesService.openUserSettings({ jsonEditor: true, revealSetting: { key: `[${languageId}]`, edit: true } }); + } else { + return this.preferencesService.openUserSettings({ query: `@lang:${languageId}` }); + } } } return undefined; From 8e98e74bdc8f741e3a4c4f4c703a539073c27104 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 28 Mar 2022 12:03:53 +0530 Subject: [PATCH 3/4] proper fix --- .../preferences/browser/preferencesActions.ts | 8 +------- .../preferences/browser/preferencesService.ts | 12 ++++++++++++ .../services/preferences/common/preferences.ts | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts index 73f5b9268b173..de3fa023e3eb8 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts @@ -11,7 +11,6 @@ import { ILanguageService } from 'vs/editor/common/languages/language'; import * as nls from 'vs/nls'; import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export class ConfigureLanguageBasedSettingsAction extends Action { @@ -25,7 +24,6 @@ export class ConfigureLanguageBasedSettingsAction extends Action { @ILanguageService private readonly languageService: ILanguageService, @IQuickInputService private readonly quickInputService: IQuickInputService, @IPreferencesService private readonly preferencesService: IPreferencesService, - @IConfigurationService private readonly configurationService: IConfigurationService, ) { super(id, label); } @@ -57,11 +55,7 @@ export class ConfigureLanguageBasedSettingsAction extends Action { if (pick) { const languageId = this.languageService.getLanguageIdByLanguageName(pick.label); if (typeof languageId === 'string') { - if (this.configurationService.getValue('workbench.settings.editor') === 'json') { - return this.preferencesService.openUserSettings({ jsonEditor: true, revealSetting: { key: `[${languageId}]`, edit: true } }); - } else { - return this.preferencesService.openUserSettings({ query: `@lang:${languageId}` }); - } + 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; From 4e20ea5f6ee55bea0f902d0362cdb1653800dac3 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 28 Mar 2022 12:05:03 +0530 Subject: [PATCH 4/4] remove unnecessary comma --- .../workbench/contrib/preferences/browser/preferencesActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts index de3fa023e3eb8..8ec573cce1e76 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesActions.ts @@ -23,7 +23,7 @@ export class ConfigureLanguageBasedSettingsAction extends Action { @IModelService private readonly modelService: IModelService, @ILanguageService private readonly languageService: ILanguageService, @IQuickInputService private readonly quickInputService: IQuickInputService, - @IPreferencesService private readonly preferencesService: IPreferencesService, + @IPreferencesService private readonly preferencesService: IPreferencesService ) { super(id, label); }