@@ -11,19 +11,20 @@ import { IModelService } from 'vs/editor/common/services/modelService';
1111import { IModeService } from 'vs/editor/common/services/modeService' ;
1212import { ITextModelService } from 'vs/editor/common/services/resolverService' ;
1313import * as nls from 'vs/nls' ;
14- import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
14+ import { ConfigurationTarget , IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
1515import { ConfigurationScope , Extensions , IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry' ;
1616import { IEditorOptions , ITextEditorOptions } from 'vs/platform/editor/common/editor' ;
1717import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
1818import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry' ;
1919import { Registry } from 'vs/platform/registry/common/platform' ;
2020import { IWorkspaceContextService , WorkbenchState } from 'vs/platform/workspace/common/workspace' ;
21+ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration' ;
2122import { IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
22- import { IEditorInput } from 'vs/workbench/common/editor' ;
23+ import { IEditorInputWithOptions } from 'vs/workbench/common/editor' ;
2324import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService' ;
24- import { IEditorService , IOpenEditorOverride } from 'vs/workbench/services/editor/common/editorService ' ;
25+ import { ContributedEditorPriority , IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService ' ;
2526import { FOLDER_SETTINGS_PATH , IPreferencesService , USE_SPLIT_JSON_SETTING } from 'vs/workbench/services/preferences/common/preferences' ;
26- import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration ' ;
27+ import { PreferencesEditorInput } from 'vs/workbench/services/preferences/ common/preferencesEditorInput ' ;
2728
2829const schemaRegistry = Registry . as < JSONContributionRegistry . IJSONContributionRegistry > ( JSONContributionRegistry . Extensions . JSONContribution ) ;
2930
@@ -36,10 +37,10 @@ export class PreferencesContribution implements IWorkbenchContribution {
3637 @ITextModelService private readonly textModelResolverService : ITextModelService ,
3738 @IPreferencesService private readonly preferencesService : IPreferencesService ,
3839 @IModeService private readonly modeService : IModeService ,
39- @IEditorService private readonly editorService : IEditorService ,
4040 @IEnvironmentService private readonly environmentService : IEnvironmentService ,
4141 @IWorkspaceContextService private readonly workspaceService : IWorkspaceContextService ,
42- @IConfigurationService private readonly configurationService : IConfigurationService
42+ @IConfigurationService private readonly configurationService : IConfigurationService ,
43+ @IEditorOverrideService private readonly editorOverrideService : IEditorOverrideService ,
4344 ) {
4445 this . settingsListener = this . configurationService . onDidChangeConfiguration ( e => {
4546 if ( e . affectsConfiguration ( USE_SPLIT_JSON_SETTING ) ) {
@@ -58,54 +59,45 @@ export class PreferencesContribution implements IWorkbenchContribution {
5859
5960 // install editor opening listener unless user has disabled this
6061 if ( ! ! this . configurationService . getValue ( USE_SPLIT_JSON_SETTING ) ) {
61- this . editorOpeningListener = this . editorService . overrideOpenEditor ( {
62- open : ( editor , options , group ) => this . onEditorOpening ( editor , options , group )
63- } ) ;
64- }
65- }
66-
67- private onEditorOpening ( editor : IEditorInput , options : IEditorOptions | ITextEditorOptions | undefined , group : IEditorGroup ) : IOpenEditorOverride | undefined {
68- const resource = editor . resource ;
69- if (
70- ! resource ||
71- ! resource . path . endsWith ( 'settings.json' ) || // resource must end in settings.json
72- ! this . configurationService . getValue ( USE_SPLIT_JSON_SETTING ) // user has not disabled default settings editor
73- ) {
74- return undefined ;
75- }
76-
77- // If the resource was already opened before in the group, do not prevent
78- // the opening of that resource. Otherwise we would have the same settings
79- // opened twice (https://github.com/microsoft/vscode/issues/36447)
80- if ( group . contains ( editor ) ) {
81- return undefined ;
82- }
62+ this . editorOpeningListener = this . editorOverrideService . registerContributionPoint (
63+ '**/settings.json' ,
64+ {
65+ id : PreferencesEditorInput . ID ,
66+ describes : editor => editor instanceof PreferencesEditorInput ,
67+ detail : 'Split Settings Editor (deprecated)' ,
68+ label : 'label' ,
69+ priority : ContributedEditorPriority . builtin ,
70+ } ,
71+ { } ,
72+ ( resource : URI , options : IEditorOptions | ITextEditorOptions | undefined , group : IEditorGroup ) : IEditorInputWithOptions => {
73+ // Global User Settings File
74+ if ( isEqual ( resource , this . environmentService . settingsResource ) ) {
75+ return { editor : this . preferencesService . getCurrentOrNewSplitJsonEditorInput ( ConfigurationTarget . USER_LOCAL , resource , group ) , options } ;
76+ }
8377
84- // Global User Settings File
85- if ( isEqual ( resource , this . environmentService . settingsResource ) ) {
86- return { override : this . preferencesService . openGlobalSettings ( true , options , group ) } ;
87- }
78+ // Single Folder Workspace Settings File
79+ const state = this . workspaceService . getWorkbenchState ( ) ;
80+ if ( state === WorkbenchState . FOLDER ) {
81+ const folders = this . workspaceService . getWorkspace ( ) . folders ;
82+ if ( isEqual ( resource , folders [ 0 ] . toResource ( FOLDER_SETTINGS_PATH ) ) ) {
83+ return { editor : this . preferencesService . getCurrentOrNewSplitJsonEditorInput ( ConfigurationTarget . WORKSPACE , resource , group ) , options } ;
84+ }
85+ }
8886
89- // Single Folder Workspace Settings File
90- const state = this . workspaceService . getWorkbenchState ( ) ;
91- if ( state === WorkbenchState . FOLDER ) {
92- const folders = this . workspaceService . getWorkspace ( ) . folders ;
93- if ( isEqual ( resource , folders [ 0 ] . toResource ( FOLDER_SETTINGS_PATH ) ) ) {
94- return { override : this . preferencesService . openWorkspaceSettings ( true , options , group ) } ;
95- }
96- }
87+ // Multi Folder Workspace Settings File
88+ else if ( state === WorkbenchState . WORKSPACE ) {
89+ const folders = this . workspaceService . getWorkspace ( ) . folders ;
90+ for ( const folder of folders ) {
91+ if ( isEqual ( resource , folder . toResource ( FOLDER_SETTINGS_PATH ) ) ) {
92+ return { editor : this . preferencesService . getCurrentOrNewSplitJsonEditorInput ( ConfigurationTarget . WORKSPACE_FOLDER , resource , group ) , options } ;
93+ }
94+ }
95+ }
9796
98- // Multi Folder Workspace Settings File
99- else if ( state === WorkbenchState . WORKSPACE ) {
100- const folders = this . workspaceService . getWorkspace ( ) . folders ;
101- for ( const folder of folders ) {
102- if ( isEqual ( resource , folder . toResource ( FOLDER_SETTINGS_PATH ) ) ) {
103- return { override : this . preferencesService . openFolderSettings ( folder . uri , true , options , group ) } ;
97+ return { editor : this . preferencesService . getCurrentOrNewSplitJsonEditorInput ( ConfigurationTarget . USER_LOCAL , this . environmentService . settingsResource , group ) , options } ;
10498 }
105- }
99+ ) ;
106100 }
107-
108- return undefined ;
109101 }
110102
111103 private start ( ) : void {
0 commit comments