提交 14fdf301 编写于 作者: R Rob Lourens

Support settings openToSide and begin refactor

#123282
上级 6269995f
...@@ -1192,7 +1192,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi ...@@ -1192,7 +1192,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
group: '2_configure', group: '2_configure',
when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.has('extensionHasConfiguration')) when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.has('extensionHasConfiguration'))
}, },
run: async (accessor: ServicesAccessor, id: string) => accessor.get(IPreferencesService).openSettings(false, `@ext:${id}`) run: async (accessor: ServicesAccessor, id: string) => accessor.get(IPreferencesService).openSettings({ jsonEditor: false, query: `@ext:${id}` })
}); });
this.registerExtensionAction({ this.registerExtensionAction({
......
...@@ -394,7 +394,7 @@ class ConfigureSaveConflictAction extends Action { ...@@ -394,7 +394,7 @@ class ConfigureSaveConflictAction extends Action {
} }
override async run(): Promise<void> { override async run(): Promise<void> {
this.preferencesService.openSettings(undefined, 'files.saveConflictResolution'); this.preferencesService.openSettings({ query: 'files.saveConflictResolution' });
} }
} }
......
...@@ -1955,7 +1955,7 @@ registerAction2(class NotebookConfigureLayoutAction extends Action2 { ...@@ -1955,7 +1955,7 @@ registerAction2(class NotebookConfigureLayoutAction extends Action2 {
}); });
} }
run(accessor: ServicesAccessor): void { run(accessor: ServicesAccessor): void {
accessor.get(IPreferencesService).openSettings(false, '@tag:notebookLayout'); accessor.get(IPreferencesService).openSettings({ jsonEditor: false, query: '@tag:notebookLayout' });
} }
}); });
......
...@@ -120,6 +120,11 @@ const OPEN_SETTINGS2_ACTION_TITLE = { value: nls.localize('openSettings2', "Open ...@@ -120,6 +120,11 @@ const OPEN_SETTINGS2_ACTION_TITLE = { value: nls.localize('openSettings2', "Open
const category = { value: nls.localize('preferences', "Preferences"), original: 'Preferences' }; const category = { value: nls.localize('preferences', "Preferences"), original: 'Preferences' };
interface IOpenSettingsActionOptions {
openToSide?: boolean;
query?: string;
}
class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution { class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution {
constructor( constructor(
...@@ -158,9 +163,10 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon ...@@ -158,9 +163,10 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
} }
}); });
} }
run(accessor: ServicesAccessor, args: string | undefined) { run(accessor: ServicesAccessor, args: string | IOpenSettingsActionOptions) {
const query = typeof args === 'string' ? args : undefined; // args takes a string for backcompat
return accessor.get(IPreferencesService).openSettings(query ? false : undefined, query); const opts = typeof args === 'string' ? { query: args } : args;
return accessor.get(IPreferencesService).openSettings(opts);
} }
}); });
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
...@@ -181,7 +187,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon ...@@ -181,7 +187,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
}); });
} }
run(accessor: ServicesAccessor) { run(accessor: ServicesAccessor) {
return accessor.get(IPreferencesService).openSettings(false, undefined); return accessor.get(IPreferencesService).openSettings({ jsonEditor: false });
} }
}); });
registerAction2(class extends Action2 { registerAction2(class extends Action2 {
...@@ -194,7 +200,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon ...@@ -194,7 +200,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
}); });
} }
run(accessor: ServicesAccessor) { run(accessor: ServicesAccessor) {
return accessor.get(IPreferencesService).openSettings(true, undefined); return accessor.get(IPreferencesService).openSettings({ jsonEditor: true });
} }
}); });
registerAction2(class extends Action2 { registerAction2(class extends Action2 {
...@@ -406,7 +412,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon ...@@ -406,7 +412,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
if (editorPane instanceof SettingsEditor2) { if (editorPane instanceof SettingsEditor2) {
editorPane.focusSearch(`@tag:usesOnlineServices`); editorPane.focusSearch(`@tag:usesOnlineServices`);
} else { } else {
accessor.get(IPreferencesService).openSettings(false, '@tag:usesOnlineServices'); accessor.get(IPreferencesService).openSettings({ jsonEditor: false, query: '@tag:usesOnlineServices' });
} }
} }
}); });
...@@ -444,7 +450,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon ...@@ -444,7 +450,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
if (editorPane instanceof SettingsEditor2) { if (editorPane instanceof SettingsEditor2) {
editorPane.focusSearch('@tag:telemetry'); editorPane.focusSearch('@tag:telemetry');
} else { } else {
accessor.get(IPreferencesService).openSettings(false, '@tag:telemetry'); accessor.get(IPreferencesService).openSettings({ jsonEditor: false, query: '@tag:telemetry' });
} }
} }
}); });
......
...@@ -46,7 +46,7 @@ import { settingsTextInputBorder } from 'vs/workbench/contrib/preferences/browse ...@@ -46,7 +46,7 @@ import { settingsTextInputBorder } from 'vs/workbench/contrib/preferences/browse
import { createTOCIterator, TOCTree, TOCTreeModel } from 'vs/workbench/contrib/preferences/browser/tocTree'; import { createTOCIterator, TOCTree, TOCTreeModel } from 'vs/workbench/contrib/preferences/browser/tocTree';
import { CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, EXTENSION_SETTING_TAG, FEATURE_SETTING_TAG, ID_SETTING_TAG, IPreferencesSearchService, ISearchProvider, MODIFIED_SETTING_TAG, REQUIRE_TRUSTED_WORKSPACE_SETTING_TAG, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, WORKSPACE_TRUST_SETTING_TAG } from 'vs/workbench/contrib/preferences/common/preferences'; import { CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, EXTENSION_SETTING_TAG, FEATURE_SETTING_TAG, ID_SETTING_TAG, IPreferencesSearchService, ISearchProvider, MODIFIED_SETTING_TAG, REQUIRE_TRUSTED_WORKSPACE_SETTING_TAG, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, WORKSPACE_TRUST_SETTING_TAG } from 'vs/workbench/contrib/preferences/common/preferences';
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { validateSettingsEditorOptions, IPreferencesService, ISearchResult, ISettingsEditorModel, ISettingsEditorOptions, SettingValueType } from 'vs/workbench/services/preferences/common/preferences'; import { IPreferencesService, ISearchResult, ISettingsEditorModel, ISettingsEditorOptions, SettingValueType, validateSettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput'; import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
import { Settings2EditorModel } from 'vs/workbench/services/preferences/common/preferencesModels'; import { Settings2EditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
import { IUserDataSyncWorkbenchService } from 'vs/workbench/services/userDataSync/common/userDataSync'; import { IUserDataSyncWorkbenchService } from 'vs/workbench/services/userDataSync/common/userDataSync';
......
...@@ -1789,7 +1789,7 @@ export function registerTerminalActions() { ...@@ -1789,7 +1789,7 @@ export function registerTerminalActions() {
}); });
} }
async run(accessor: ServicesAccessor) { async run(accessor: ServicesAccessor) {
await accessor.get(IPreferencesService).openSettings(false, '@feature:terminal'); await accessor.get(IPreferencesService).openSettings({ jsonEditor: false, query: '@feature:terminal' });
} }
}); });
......
...@@ -761,7 +761,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { ...@@ -761,7 +761,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
{ {
label: nls.localize('configureTerminalSettings', "Configure Terminal Settings"), label: nls.localize('configureTerminalSettings', "Configure Terminal Settings"),
run: () => { run: () => {
this._preferencesService.openSettings(false, `@id:${TerminalSettingId.CommandsToSkipShell},${TerminalSettingId.SendKeybindingsToShell},${TerminalSettingId.AllowChords}`); this._preferencesService.openSettings({ jsonEditor: false, query: `@id:${TerminalSettingId.CommandsToSkipShell},${TerminalSettingId.SendKeybindingsToShell},${TerminalSettingId.AllowChords}` });
} }
} as IPromptChoice } as IPromptChoice
] ]
......
...@@ -37,9 +37,9 @@ import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEdit ...@@ -37,9 +37,9 @@ import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEdit
import { TextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput'; import { TextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing'; import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
import { GroupDirection, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { GroupDirection, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { KeybindingsEditorInput } from 'vs/workbench/services/preferences/browser/keybindingsEditorInput'; import { KeybindingsEditorInput } from 'vs/workbench/services/preferences/browser/keybindingsEditorInput';
import { DEFAULT_SETTINGS_EDITOR_SETTING, FOLDER_SETTINGS_PATH, IKeybindingsEditorOptions, IKeybindingsEditorPane, IPreferencesEditorModel, IPreferencesService, ISetting, ISettingsEditorOptions, USE_SPLIT_JSON_SETTING, validateSettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences'; import { DEFAULT_SETTINGS_EDITOR_SETTING, FOLDER_SETTINGS_PATH, IKeybindingsEditorOptions, IKeybindingsEditorPane, IOpenSettingsOptions, IPreferencesEditorModel, IPreferencesService, ISetting, ISettingsEditorOptions, USE_SPLIT_JSON_SETTING, validateSettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput'; import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
import { defaultKeybindingsContents, DefaultKeybindingsEditorModel, DefaultRawSettingsEditorModel, DefaultSettings, DefaultSettingsEditorModel, Settings2EditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels'; import { defaultKeybindingsContents, DefaultKeybindingsEditorModel, DefaultRawSettingsEditorModel, DefaultSettings, DefaultSettingsEditorModel, Settings2EditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
...@@ -201,25 +201,29 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -201,25 +201,29 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.editorService.openEditor({ resource: this.userSettingsResource }); return this.editorService.openEditor({ resource: this.userSettingsResource });
} }
openSettings(jsonEditor: boolean | undefined, query: string | undefined): Promise<IEditorPane | undefined> { private shouldOpenJsonByDefault(): boolean {
jsonEditor = typeof jsonEditor === 'undefined' ? return this.configurationService.getValue('workbench.settings.editor') === 'json';
this.configurationService.getValue('workbench.settings.editor') === 'json' : }
jsonEditor;
openSettings(options: IOpenSettingsOptions = {}): Promise<IEditorPane | undefined> {
if (typeof options.jsonEditor !== 'boolean') {
options.jsonEditor = this.shouldOpenJsonByDefault();
}
if (!jsonEditor) { if (!options.jsonEditor) {
return this.openSettings2({ query: query }); return this.openSettings2(options);
} }
return this.openSettingsJson(ConfigurationTarget.USER_LOCAL, this.userSettingsResource, { query: query }); return this.openSettingsJson(ConfigurationTarget.USER_LOCAL, this.userSettingsResource, options);
} }
private async openSettings2(options?: ISettingsEditorOptions): Promise<IEditorPane> { private async openSettings2(options?: IOpenSettingsOptions): Promise<IEditorPane> {
const input = this.settingsEditor2Input; const input = this.settingsEditor2Input;
options = { options = {
...options, ...options,
focusSearch: true focusSearch: true
}; };
await this.editorService.openEditor(input, validateSettingsEditorOptions(options)); await this.editorService.openEditor(input, validateSettingsEditorOptions(options), options.openToSide ? SIDE_GROUP : undefined);
return this.editorGroupService.activeGroup.activeEditorPane!; return this.editorGroupService.activeGroup.activeEditorPane!;
} }
......
...@@ -176,6 +176,11 @@ export interface ISettingsEditorOptions extends IEditorOptions { ...@@ -176,6 +176,11 @@ export interface ISettingsEditorOptions extends IEditorOptions {
focusSearch?: boolean; focusSearch?: boolean;
} }
export interface IOpenSettingsOptions extends ISettingsEditorOptions {
jsonEditor?: boolean;
openToSide?: boolean;
}
export function validateSettingsEditorOptions(options: ISettingsEditorOptions): ISettingsEditorOptions { export function validateSettingsEditorOptions(options: ISettingsEditorOptions): ISettingsEditorOptions {
return { return {
// Inherit provided options // Inherit provided options
...@@ -208,7 +213,7 @@ export interface IPreferencesService { ...@@ -208,7 +213,7 @@ export interface IPreferencesService {
createSettings2EditorModel(): Settings2EditorModel; // TODO createSettings2EditorModel(): Settings2EditorModel; // TODO
openRawDefaultSettings(): Promise<IEditorPane | undefined>; openRawDefaultSettings(): Promise<IEditorPane | undefined>;
openSettings(jsonEditor: boolean | undefined, query: string | undefined): Promise<IEditorPane | undefined>; openSettings(options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditorPane | undefined>; openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditorPane | undefined>;
openRemoteSettings(): Promise<IEditorPane | undefined>; openRemoteSettings(): Promise<IEditorPane | undefined>;
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditorPane | undefined>; openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditorPane | undefined>;
......
...@@ -41,7 +41,7 @@ suite('PreferencesService', () => { ...@@ -41,7 +41,7 @@ suite('PreferencesService', () => {
}); });
test('options are preserved when calling openEditor', async () => { test('options are preserved when calling openEditor', async () => {
testObject.openSettings(false, 'test query'); testObject.openSettings({ jsonEditor: false, query: 'test query' });
const options = editorService.lastOpenEditorOptions as ISettingsEditorOptions; const options = editorService.lastOpenEditorOptions as ISettingsEditorOptions;
assert.strictEqual(options.focusSearch, true); assert.strictEqual(options.focusSearch, true);
assert.strictEqual(options.override, EditorResolution.DISABLED); assert.strictEqual(options.override, EditorResolution.DISABLED);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册