Skip to content

Commit 4926415

Browse files
authored
1 parent 3a931d9 commit 4926415

File tree

5 files changed

+185
-245
lines changed

5 files changed

+185
-245
lines changed

src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
7878
import { IStringDictionary } from 'vs/base/common/collections';
7979
import { CONTEXT_KEYBINDINGS_EDITOR } from 'vs/workbench/contrib/preferences/common/preferences';
8080
import { DeprecatedExtensionsChecker } from 'vs/workbench/contrib/extensions/browser/deprecatedExtensionsChecker';
81-
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
8281

8382
// Singletons
8483
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService, InstantiationType.Eager /* Auto updates extensions */);
@@ -473,7 +472,6 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
473472
@IInstantiationService private readonly instantiationService: IInstantiationService,
474473
@IDialogService private readonly dialogService: IDialogService,
475474
@ICommandService private readonly commandService: ICommandService,
476-
@IUserDataProfileService private readonly userDataProfileService: IUserDataProfileService,
477475
) {
478476
super();
479477
const hasGalleryContext = CONTEXT_HAS_GALLERY.bindTo(contextKeyService);
@@ -517,31 +515,22 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
517515

518516
// Global actions
519517
private registerGlobalActions(): void {
520-
const getTitle = (title: string) => !this.userDataProfileService.currentProfile.isDefault && this.userDataProfileService.currentProfile.useDefaultFlags?.extensions
521-
? `${title} (${localize('default profile', "Default Profile")})`
522-
: title;
523-
const registerOpenExtensionsActionDisposables = this._register(new DisposableStore());
524-
const registerOpenExtensionsAction = () => {
525-
registerOpenExtensionsActionDisposables.clear();
526-
registerOpenExtensionsActionDisposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
527-
command: {
528-
id: VIEWLET_ID,
529-
title: getTitle(localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions"))
530-
},
531-
group: '2_configuration',
532-
order: 3
533-
}));
534-
registerOpenExtensionsActionDisposables.add(MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
535-
command: {
536-
id: VIEWLET_ID,
537-
title: getTitle(localize('showExtensions', "Extensions"))
538-
},
539-
group: '2_configuration',
540-
order: 3
541-
}));
542-
};
543-
registerOpenExtensionsAction();
544-
this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenExtensionsAction()));
518+
this._register(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
519+
command: {
520+
id: VIEWLET_ID,
521+
title: localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions")
522+
},
523+
group: '2_configuration',
524+
order: 3
525+
}));
526+
this._register(MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
527+
command: {
528+
id: VIEWLET_ID,
529+
title: localize('showExtensions', "Extensions")
530+
},
531+
group: '2_configuration',
532+
order: 3
533+
}));
545534

546535
this.registerExtensionAction({
547536
id: 'workbench.extensions.action.installExtensions',

src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts

Lines changed: 75 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -187,46 +187,37 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
187187
}
188188

189189
private registerSettingsActions() {
190-
const registerOpenSettingsActionDisposables = this._register(new DisposableStore());
191-
const registerOpenSettingsAction = () => {
192-
registerOpenSettingsActionDisposables.clear();
193-
const getTitle = (title: string) => !this.userDataProfileService.currentProfile.isDefault && this.userDataProfileService.currentProfile.useDefaultFlags?.settings
194-
? `${title} (${nls.localize('default profile', "Default Profile")})`
195-
: title;
196-
registerOpenSettingsActionDisposables.add(registerAction2(class extends Action2 {
197-
constructor() {
198-
super({
199-
id: SETTINGS_COMMAND_OPEN_SETTINGS,
200-
title: {
201-
value: getTitle(nls.localize('settings', "Settings")),
202-
mnemonicTitle: getTitle(nls.localize({ key: 'miOpenSettings', comment: ['&& denotes a mnemonic'] }, "&&Settings")),
203-
original: 'Settings'
204-
},
205-
keybinding: {
206-
weight: KeybindingWeight.WorkbenchContrib,
207-
when: null,
208-
primary: KeyMod.CtrlCmd | KeyCode.Comma,
209-
},
210-
menu: [{
211-
id: MenuId.GlobalActivity,
212-
group: '2_configuration',
213-
order: 1
214-
}, {
215-
id: MenuId.MenubarPreferencesMenu,
216-
group: '2_configuration',
217-
order: 1
218-
}],
219-
});
220-
}
221-
run(accessor: ServicesAccessor, args: string | IOpenSettingsActionOptions) {
222-
// args takes a string for backcompat
223-
const opts = typeof args === 'string' ? { query: args } : sanitizeOpenSettingsArgs(args);
224-
return accessor.get(IPreferencesService).openSettings(opts);
225-
}
226-
}));
227-
};
228-
registerOpenSettingsAction();
229-
this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenSettingsAction()));
190+
this._register(registerAction2(class extends Action2 {
191+
constructor() {
192+
super({
193+
id: SETTINGS_COMMAND_OPEN_SETTINGS,
194+
title: {
195+
value: nls.localize('settings', "Settings"),
196+
mnemonicTitle: nls.localize({ key: 'miOpenSettings', comment: ['&& denotes a mnemonic'] }, "&&Settings"),
197+
original: 'Settings'
198+
},
199+
keybinding: {
200+
weight: KeybindingWeight.WorkbenchContrib,
201+
when: null,
202+
primary: KeyMod.CtrlCmd | KeyCode.Comma,
203+
},
204+
menu: [{
205+
id: MenuId.GlobalActivity,
206+
group: '2_configuration',
207+
order: 1
208+
}, {
209+
id: MenuId.MenubarPreferencesMenu,
210+
group: '2_configuration',
211+
order: 1
212+
}],
213+
});
214+
}
215+
run(accessor: ServicesAccessor, args: string | IOpenSettingsActionOptions) {
216+
// args takes a string for backcompat
217+
const opts = typeof args === 'string' ? { query: args } : sanitizeOpenSettingsArgs(args);
218+
return accessor.get(IPreferencesService).openSettings(opts);
219+
}
220+
}));
230221
registerAction2(class extends Action2 {
231222
constructor() {
232223
super({
@@ -305,13 +296,13 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
305296
}
306297
});
307298

308-
const registerOpenUserSettingsEditorFromJsonActionDisposable = this._register(new MutableDisposable());
299+
const registerOpenUserSettingsEditorFromJsonActionDisposables = this._register(new MutableDisposable());
309300
const openUserSettingsEditorWhen = ContextKeyExpr.and(
310301
ContextKeyExpr.or(ResourceContextKey.Resource.isEqualTo(this.userDataProfileService.currentProfile.settingsResource.toString()),
311302
ResourceContextKey.Resource.isEqualTo(this.userDataProfilesService.defaultProfile.settingsResource.toString())),
312303
ContextKeyExpr.not('isInDiffEditor'));
313304
const registerOpenUserSettingsEditorFromJsonAction = () => {
314-
registerOpenUserSettingsEditorFromJsonActionDisposable.value = registerAction2(class extends Action2 {
305+
registerOpenUserSettingsEditorFromJsonActionDisposables.value = registerAction2(class extends Action2 {
315306
constructor() {
316307
super({
317308
id: '_workbench.openUserSettingsEditor',
@@ -815,58 +806,49 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
815806
private registerKeybindingsActions() {
816807
const that = this;
817808
const category = { value: nls.localize('preferences', "Preferences"), original: 'Preferences' };
818-
const registerOpenGlobalKeybindingsActionDisposables = this._register(new DisposableStore());
819-
const registerOpenGlobalKeybindingsAction = () => {
820-
registerOpenGlobalKeybindingsActionDisposables.clear();
821-
const id = 'workbench.action.openGlobalKeybindings';
822-
const shortTitle = !that.userDataProfileService.currentProfile.isDefault && that.userDataProfileService.currentProfile.useDefaultFlags?.keybindings
823-
? nls.localize('keyboardShortcutsFromDefault', "Keyboard Shortcuts ({0})", nls.localize('default profile', "Default Profile"))
824-
: nls.localize('keyboardShortcuts', "Keyboard Shortcuts");
825-
registerOpenGlobalKeybindingsActionDisposables.add(registerAction2(class extends Action2 {
826-
constructor() {
827-
super({
828-
id,
829-
title: { value: nls.localize('openGlobalKeybindings', "Open Keyboard Shortcuts"), original: 'Open Keyboard Shortcuts' },
830-
shortTitle,
831-
category,
832-
icon: preferencesOpenSettingsIcon,
833-
keybinding: {
834-
when: null,
835-
weight: KeybindingWeight.WorkbenchContrib,
836-
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyS)
837-
},
838-
menu: [
839-
{ id: MenuId.CommandPalette },
840-
{
841-
id: MenuId.EditorTitle,
842-
when: ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.keybindingsResource.toString()),
843-
group: 'navigation',
844-
order: 1,
845-
},
846-
{
847-
id: MenuId.GlobalActivity,
848-
group: '2_configuration',
849-
order: 3
850-
}
851-
]
852-
});
853-
}
854-
run(accessor: ServicesAccessor, args: string | undefined) {
855-
const query = typeof args === 'string' ? args : undefined;
856-
return accessor.get(IPreferencesService).openGlobalKeybindingSettings(false, { query });
857-
}
858-
}));
859-
registerOpenGlobalKeybindingsActionDisposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
860-
command: {
809+
const id = 'workbench.action.openGlobalKeybindings';
810+
this._register(registerAction2(class extends Action2 {
811+
constructor() {
812+
super({
861813
id,
862-
title: shortTitle,
863-
},
864-
group: '2_configuration',
865-
order: 3
866-
}));
867-
};
868-
registerOpenGlobalKeybindingsAction();
869-
this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenGlobalKeybindingsAction()));
814+
title: { value: nls.localize('openGlobalKeybindings', "Open Keyboard Shortcuts"), original: 'Open Keyboard Shortcuts' },
815+
shortTitle: nls.localize('keyboardShortcuts', "Keyboard Shortcuts"),
816+
category,
817+
icon: preferencesOpenSettingsIcon,
818+
keybinding: {
819+
when: null,
820+
weight: KeybindingWeight.WorkbenchContrib,
821+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyS)
822+
},
823+
menu: [
824+
{ id: MenuId.CommandPalette },
825+
{
826+
id: MenuId.EditorTitle,
827+
when: ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.keybindingsResource.toString()),
828+
group: 'navigation',
829+
order: 1,
830+
},
831+
{
832+
id: MenuId.GlobalActivity,
833+
group: '2_configuration',
834+
order: 3
835+
}
836+
]
837+
});
838+
}
839+
run(accessor: ServicesAccessor, args: string | undefined) {
840+
const query = typeof args === 'string' ? args : undefined;
841+
return accessor.get(IPreferencesService).openGlobalKeybindingSettings(false, { query });
842+
}
843+
}));
844+
this._register(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
845+
command: {
846+
id,
847+
title: nls.localize('keyboardShortcuts', "Keyboard Shortcuts"),
848+
},
849+
group: '2_configuration',
850+
order: 3
851+
}));
870852
registerAction2(class extends Action2 {
871853
constructor() {
872854
super({

0 commit comments

Comments
 (0)