Skip to content

Commit

Permalink
Merge pull request #146163 from microsoft/sandy081/fix146161
Browse files Browse the repository at this point in the history
Open settings UI editor while configuring language specific settings
  • Loading branch information
sandy081 authored Mar 28, 2022
2 parents 0aad3c8 + 4e20ea5 commit 660f140
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.open(this.userSettingsResource, options);
}

openLanguageSpecificSettings(languageId: string, options: IOpenSettingsOptions = {}): Promise<IEditorPane | undefined> {
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<IEditorPane | undefined> {
options = {
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export interface IPreferencesService {
openFolderSettings(options: IOpenSettingsOptions & { folderUri: IOpenSettingsOptions['folderUri'] }): Promise<IEditorPane | undefined>;
openGlobalKeybindingSettings(textual: boolean, options?: IKeybindingsEditorOptions): Promise<void>;
openDefaultKeybindingsFile(): Promise<IEditorPane | undefined>;
openLanguageSpecificSettings(language: string, options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): Promise<URI | null>;

createSplitJsonEditorInput(configurationTarget: ConfigurationTarget, resource: URI): EditorInput;
Expand Down

0 comments on commit 660f140

Please sign in to comment.