@@ -296,64 +296,6 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
296296 }
297297 } ) ;
298298
299- const registerOpenUserSettingsEditorFromJsonActionDisposables = this . _register ( new MutableDisposable ( ) ) ;
300- const openUserSettingsEditorWhen = ContextKeyExpr . and (
301- ContextKeyExpr . or ( ResourceContextKey . Resource . isEqualTo ( this . userDataProfileService . currentProfile . settingsResource . toString ( ) ) ,
302- ResourceContextKey . Resource . isEqualTo ( this . userDataProfilesService . defaultProfile . settingsResource . toString ( ) ) ) ,
303- ContextKeyExpr . not ( 'isInDiffEditor' ) ) ;
304- const registerOpenUserSettingsEditorFromJsonAction = ( ) => {
305- registerOpenUserSettingsEditorFromJsonActionDisposables . value = registerAction2 ( class extends Action2 {
306- constructor ( ) {
307- super ( {
308- id : '_workbench.openUserSettingsEditor' ,
309- title : OPEN_USER_SETTINGS_UI_TITLE ,
310- icon : preferencesOpenSettingsIcon ,
311- menu : [ {
312- id : MenuId . EditorTitle ,
313- when : openUserSettingsEditorWhen ,
314- group : 'navigation' ,
315- order : 1
316- } ]
317- } ) ;
318- }
319- run ( accessor : ServicesAccessor , args : IOpenSettingsActionOptions ) {
320- args = sanitizeOpenSettingsArgs ( args ) ;
321- return accessor . get ( IPreferencesService ) . openUserSettings ( { jsonEditor : false , ...args } ) ;
322- }
323- } ) ;
324- } ;
325-
326- const openSettingsJsonWhen = ContextKeyExpr . and ( CONTEXT_SETTINGS_EDITOR , CONTEXT_SETTINGS_JSON_EDITOR . toNegated ( ) ) ;
327- registerAction2 ( class extends Action2 {
328- constructor ( ) {
329- super ( {
330- id : SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON ,
331- title : { value : nls . localize ( 'openSettingsJson' , "Open Settings (JSON)" ) , original : 'Open Settings (JSON)' } ,
332- icon : preferencesOpenSettingsIcon ,
333- menu : [ {
334- id : MenuId . EditorTitle ,
335- when : openSettingsJsonWhen ,
336- group : 'navigation' ,
337- order : 1
338- } ]
339- } ) ;
340- }
341- run ( accessor : ServicesAccessor ) {
342- const editorPane = accessor . get ( IEditorService ) . activeEditorPane ;
343- if ( editorPane instanceof SettingsEditor2 ) {
344- return editorPane . switchToSettingsFile ( ) ;
345- }
346- return null ;
347- }
348- } ) ;
349-
350- registerOpenUserSettingsEditorFromJsonAction ( ) ;
351-
352- this . _register ( this . userDataProfileService . onDidChangeCurrentProfile ( ( ) => {
353- // Force the action to check the context again.
354- registerOpenUserSettingsEditorFromJsonAction ( ) ;
355- } ) ) ;
356-
357299 registerAction2 ( class extends Action2 {
358300 constructor ( ) {
359301 super ( {
@@ -1274,9 +1216,80 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
12741216 }
12751217}
12761218
1219+ class SettingsEditorTitleContribution extends Disposable implements IWorkbenchContribution {
1220+ constructor (
1221+ @IUserDataProfileService private readonly userDataProfileService : IUserDataProfileService ,
1222+ @IUserDataProfilesService private readonly userDataProfilesService : IUserDataProfilesService ,
1223+ ) {
1224+ super ( ) ;
1225+ this . registerSettingsEditorTitleActions ( ) ;
1226+ }
1227+
1228+ private registerSettingsEditorTitleActions ( ) {
1229+ const registerOpenUserSettingsEditorFromJsonActionDisposables = this . _register ( new MutableDisposable ( ) ) ;
1230+ const openUserSettingsEditorWhen = ContextKeyExpr . and (
1231+ ContextKeyExpr . or (
1232+ ResourceContextKey . Resource . isEqualTo ( this . userDataProfileService . currentProfile . settingsResource . toString ( ) ) ,
1233+ ResourceContextKey . Resource . isEqualTo ( this . userDataProfilesService . defaultProfile . settingsResource . toString ( ) ) ) ,
1234+ ContextKeyExpr . not ( 'isInDiffEditor' ) ) ;
1235+ const registerOpenUserSettingsEditorFromJsonAction = ( ) => {
1236+ registerOpenUserSettingsEditorFromJsonActionDisposables . value = registerAction2 ( class extends Action2 {
1237+ constructor ( ) {
1238+ super ( {
1239+ id : '_workbench.openUserSettingsEditor' ,
1240+ title : OPEN_USER_SETTINGS_UI_TITLE ,
1241+ icon : preferencesOpenSettingsIcon ,
1242+ menu : [ {
1243+ id : MenuId . EditorTitle ,
1244+ when : openUserSettingsEditorWhen ,
1245+ group : 'navigation' ,
1246+ order : 1
1247+ } ]
1248+ } ) ;
1249+ }
1250+ run ( accessor : ServicesAccessor , args : IOpenSettingsActionOptions ) {
1251+ args = sanitizeOpenSettingsArgs ( args ) ;
1252+ return accessor . get ( IPreferencesService ) . openUserSettings ( { jsonEditor : false , ...args } ) ;
1253+ }
1254+ } ) ;
1255+ } ;
1256+
1257+ registerOpenUserSettingsEditorFromJsonAction ( ) ;
1258+ this . _register ( this . userDataProfileService . onDidChangeCurrentProfile ( ( ) => {
1259+ // Force the action to check the context again.
1260+ registerOpenUserSettingsEditorFromJsonAction ( ) ;
1261+ } ) ) ;
1262+
1263+ const openSettingsJsonWhen = ContextKeyExpr . and ( CONTEXT_SETTINGS_EDITOR , CONTEXT_SETTINGS_JSON_EDITOR . toNegated ( ) ) ;
1264+ registerAction2 ( class extends Action2 {
1265+ constructor ( ) {
1266+ super ( {
1267+ id : SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON ,
1268+ title : { value : nls . localize ( 'openSettingsJson' , "Open Settings (JSON)" ) , original : 'Open Settings (JSON)' } ,
1269+ icon : preferencesOpenSettingsIcon ,
1270+ menu : [ {
1271+ id : MenuId . EditorTitle ,
1272+ when : openSettingsJsonWhen ,
1273+ group : 'navigation' ,
1274+ order : 1
1275+ } ]
1276+ } ) ;
1277+ }
1278+ run ( accessor : ServicesAccessor ) {
1279+ const editorPane = accessor . get ( IEditorService ) . activeEditorPane ;
1280+ if ( editorPane instanceof SettingsEditor2 ) {
1281+ return editorPane . switchToSettingsFile ( ) ;
1282+ }
1283+ return null ;
1284+ }
1285+ } ) ;
1286+ }
1287+ }
1288+
12771289const workbenchContributionsRegistry = Registry . as < IWorkbenchContributionsRegistry > ( WorkbenchExtensions . Workbench ) ;
12781290workbenchContributionsRegistry . registerWorkbenchContribution ( PreferencesActionsContribution , LifecyclePhase . Starting ) ;
12791291workbenchContributionsRegistry . registerWorkbenchContribution ( PreferencesContribution , LifecyclePhase . Starting ) ;
1292+ workbenchContributionsRegistry . registerWorkbenchContribution ( SettingsEditorTitleContribution , LifecyclePhase . Restored ) ;
12801293
12811294registerEditorContribution ( SettingsEditorContribution . ID , SettingsEditorContribution , EditorContributionInstantiation . AfterFirstRender ) ;
12821295
0 commit comments