From 661bf0dbfb04f231c19c82f40823452d8ac80b57 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 8 Aug 2016 17:36:54 +0200 Subject: [PATCH] Provide setting to not show read-only full settings buffer when opening Settings (fixes #9904) --- .../workbench/browser/actions/openSettings.ts | 19 +++++++++- .../parts/editor/editor.contribution.ts | 33 ---------------- .../electron-browser/main.contribution.ts | 38 ++++++++++++++++++- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/src/vs/workbench/browser/actions/openSettings.ts b/src/vs/workbench/browser/actions/openSettings.ts index 6cb25f93df8..45117385212 100644 --- a/src/vs/workbench/browser/actions/openSettings.ts +++ b/src/vs/workbench/browser/actions/openSettings.ts @@ -28,6 +28,14 @@ import {SyncActionDescriptor} from 'vs/platform/actions/common/actions'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {KeyMod, KeyCode} from 'vs/base/common/keyCodes'; +export interface IWorkbenchSettingsConfiguration { + workbench: { + settings: { + openDefaultSettings: boolean; + } + }; +} + export class BaseTwoEditorsAction extends Action { constructor( @@ -95,7 +103,16 @@ export class BaseOpenSettingsAction extends BaseTwoEditorsAction { } protected open(emptySettingsContents: string, settingsResource: URI): TPromise { - return this.openTwoEditors(DefaultSettingsInput.getInstance(this.instantiationService, this.configurationService), settingsResource, emptySettingsContents); + const openDefaultSettings = !!this.configurationService.getConfiguration().workbench.settings.openDefaultSettings; + + if (openDefaultSettings) { + return this.openTwoEditors(DefaultSettingsInput.getInstance(this.instantiationService, this.configurationService), settingsResource, emptySettingsContents); + } + + return this.editorService.openEditor({ + resource: settingsResource, + options: { pinned: true } + }).then(() => null); } } diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index bfe488bf55e..046c9f7107a 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -23,7 +23,6 @@ import {TextDiffEditor} from 'vs/workbench/browser/parts/editor/textDiffEditor'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {BinaryResourceDiffEditor} from 'vs/workbench/browser/parts/editor/binaryDiffEditor'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; -import {IConfigurationRegistry, Extensions as ConfigurationExtensions} from 'vs/platform/configuration/common/configurationRegistry'; import {ChangeEncodingAction, ChangeEOLAction, ChangeModeAction, EditorStatus} from 'vs/workbench/browser/parts/editor/editorStatus'; import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry'; import {Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor} from 'vs/workbench/browser/actionBarRegistry'; @@ -329,37 +328,5 @@ function toKeyCode(index: number): KeyCode { } } -// Configuration -const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); -configurationRegistry.registerConfiguration({ - 'id': 'workbench', - 'order': 7, - 'title': nls.localize('workbenchConfigurationTitle', "Workbench"), - 'type': 'object', - 'properties': { - 'workbench.editor.showTabs': { - 'type': 'boolean', - 'description': nls.localize('showEditorTabs', "Controls if opened editors should show in tabs or not."), - 'default': true - }, - 'workbench.editor.enablePreview': { - 'type': 'boolean', - 'description': nls.localize('enablePreview', "Controls if opened editors show as preview. Preview editors are reused until they are kept (e.g. via double click or editing)."), - 'default': true - }, - 'workbench.editor.enablePreviewFromQuickOpen': { - 'type': 'boolean', - 'description': nls.localize('enablePreviewFromQuickOpen', "Controls if opened editors from quick open show as preview. Preview editors are reused until they are kept (e.g. via double click or editing)."), - 'default': true - }, - 'workbench.editor.openPositioning': { - 'type': 'string', - 'enum': ['left', 'right', 'first', 'last'], - 'default': 'right', - 'description': nls.localize('editorOpenPositioning', "Controls where editors open. Select 'left' or 'right' to open editors to the left or right of the current active one. Select 'first' or 'last' to open editors independently from the currently active one.") - } - } -}); - // Editor Commands editorCommands.setup(); \ No newline at end of file diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index 100dca09925..a91f4a8eec8 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -54,8 +54,44 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ } }); -// Configuration: Window +// Configuration: Workbench const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); +configurationRegistry.registerConfiguration({ + 'id': 'workbench', + 'order': 7, + 'title': nls.localize('workbenchConfigurationTitle', "Workbench"), + 'type': 'object', + 'properties': { + 'workbench.editor.showTabs': { + 'type': 'boolean', + 'description': nls.localize('showEditorTabs', "Controls if opened editors should show in tabs or not."), + 'default': true + }, + 'workbench.editor.enablePreview': { + 'type': 'boolean', + 'description': nls.localize('enablePreview', "Controls if opened editors show as preview. Preview editors are reused until they are kept (e.g. via double click or editing)."), + 'default': true + }, + 'workbench.editor.enablePreviewFromQuickOpen': { + 'type': 'boolean', + 'description': nls.localize('enablePreviewFromQuickOpen', "Controls if opened editors from quick open show as preview. Preview editors are reused until they are kept (e.g. via double click or editing)."), + 'default': true + }, + 'workbench.editor.openPositioning': { + 'type': 'string', + 'enum': ['left', 'right', 'first', 'last'], + 'default': 'right', + 'description': nls.localize('editorOpenPositioning', "Controls where editors open. Select 'left' or 'right' to open editors to the left or right of the current active one. Select 'first' or 'last' to open editors independently from the currently active one.") + }, + 'workbench.settings.openDefaultSettings': { + 'type': 'boolean', + 'description': nls.localize('openDefaultSettings', "Controls if opening settings also opens an editor showing all default settings."), + 'default': true + } + } +}); + +// Configuration: Window configurationRegistry.registerConfiguration({ 'id': 'window', 'order': 8,