Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert #188521

Merged
merged 1 commit into from
Jul 21, 2023
Merged

revert #188521

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { IStringDictionary } from 'vs/base/common/collections';
import { CONTEXT_KEYBINDINGS_EDITOR } from 'vs/workbench/contrib/preferences/common/preferences';
import { DeprecatedExtensionsChecker } from 'vs/workbench/contrib/extensions/browser/deprecatedExtensionsChecker';
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';

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

// Global actions
private registerGlobalActions(): void {
const getTitle = (title: string) => !this.userDataProfileService.currentProfile.isDefault && this.userDataProfileService.currentProfile.useDefaultFlags?.extensions
? `${title} (${localize('default profile', "Default Profile")})`
: title;
const registerOpenExtensionsActionDisposables = this._register(new DisposableStore());
const registerOpenExtensionsAction = () => {
registerOpenExtensionsActionDisposables.clear();
registerOpenExtensionsActionDisposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
command: {
id: VIEWLET_ID,
title: getTitle(localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions"))
},
group: '2_configuration',
order: 3
}));
registerOpenExtensionsActionDisposables.add(MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
command: {
id: VIEWLET_ID,
title: getTitle(localize('showExtensions', "Extensions"))
},
group: '2_configuration',
order: 3
}));
};
registerOpenExtensionsAction();
this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenExtensionsAction()));
this._register(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
command: {
id: VIEWLET_ID,
title: localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions")
},
group: '2_configuration',
order: 3
}));
this._register(MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
command: {
id: VIEWLET_ID,
title: localize('showExtensions', "Extensions")
},
group: '2_configuration',
order: 3
}));

this.registerExtensionAction({
id: 'workbench.extensions.action.installExtensions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,46 +187,37 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
}

private registerSettingsActions() {
const registerOpenSettingsActionDisposables = this._register(new DisposableStore());
const registerOpenSettingsAction = () => {
registerOpenSettingsActionDisposables.clear();
const getTitle = (title: string) => !this.userDataProfileService.currentProfile.isDefault && this.userDataProfileService.currentProfile.useDefaultFlags?.settings
? `${title} (${nls.localize('default profile', "Default Profile")})`
: title;
registerOpenSettingsActionDisposables.add(registerAction2(class extends Action2 {
constructor() {
super({
id: SETTINGS_COMMAND_OPEN_SETTINGS,
title: {
value: getTitle(nls.localize('settings', "Settings")),
mnemonicTitle: getTitle(nls.localize({ key: 'miOpenSettings', comment: ['&& denotes a mnemonic'] }, "&&Settings")),
original: 'Settings'
},
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
when: null,
primary: KeyMod.CtrlCmd | KeyCode.Comma,
},
menu: [{
id: MenuId.GlobalActivity,
group: '2_configuration',
order: 1
}, {
id: MenuId.MenubarPreferencesMenu,
group: '2_configuration',
order: 1
}],
});
}
run(accessor: ServicesAccessor, args: string | IOpenSettingsActionOptions) {
// args takes a string for backcompat
const opts = typeof args === 'string' ? { query: args } : sanitizeOpenSettingsArgs(args);
return accessor.get(IPreferencesService).openSettings(opts);
}
}));
};
registerOpenSettingsAction();
this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenSettingsAction()));
this._register(registerAction2(class extends Action2 {
constructor() {
super({
id: SETTINGS_COMMAND_OPEN_SETTINGS,
title: {
value: nls.localize('settings', "Settings"),
mnemonicTitle: nls.localize({ key: 'miOpenSettings', comment: ['&& denotes a mnemonic'] }, "&&Settings"),
original: 'Settings'
},
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
when: null,
primary: KeyMod.CtrlCmd | KeyCode.Comma,
},
menu: [{
id: MenuId.GlobalActivity,
group: '2_configuration',
order: 1
}, {
id: MenuId.MenubarPreferencesMenu,
group: '2_configuration',
order: 1
}],
});
}
run(accessor: ServicesAccessor, args: string | IOpenSettingsActionOptions) {
// args takes a string for backcompat
const opts = typeof args === 'string' ? { query: args } : sanitizeOpenSettingsArgs(args);
return accessor.get(IPreferencesService).openSettings(opts);
}
}));
registerAction2(class extends Action2 {
constructor() {
super({
Expand Down Expand Up @@ -305,13 +296,13 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
}
});

const registerOpenUserSettingsEditorFromJsonActionDisposable = this._register(new MutableDisposable());
const registerOpenUserSettingsEditorFromJsonActionDisposables = this._register(new MutableDisposable());
const openUserSettingsEditorWhen = ContextKeyExpr.and(
ContextKeyExpr.or(ResourceContextKey.Resource.isEqualTo(this.userDataProfileService.currentProfile.settingsResource.toString()),
ResourceContextKey.Resource.isEqualTo(this.userDataProfilesService.defaultProfile.settingsResource.toString())),
ContextKeyExpr.not('isInDiffEditor'));
const registerOpenUserSettingsEditorFromJsonAction = () => {
registerOpenUserSettingsEditorFromJsonActionDisposable.value = registerAction2(class extends Action2 {
registerOpenUserSettingsEditorFromJsonActionDisposables.value = registerAction2(class extends Action2 {
constructor() {
super({
id: '_workbench.openUserSettingsEditor',
Expand Down Expand Up @@ -815,58 +806,49 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
private registerKeybindingsActions() {
const that = this;
const category = { value: nls.localize('preferences', "Preferences"), original: 'Preferences' };
const registerOpenGlobalKeybindingsActionDisposables = this._register(new DisposableStore());
const registerOpenGlobalKeybindingsAction = () => {
registerOpenGlobalKeybindingsActionDisposables.clear();
const id = 'workbench.action.openGlobalKeybindings';
const shortTitle = !that.userDataProfileService.currentProfile.isDefault && that.userDataProfileService.currentProfile.useDefaultFlags?.keybindings
? nls.localize('keyboardShortcutsFromDefault', "Keyboard Shortcuts ({0})", nls.localize('default profile', "Default Profile"))
: nls.localize('keyboardShortcuts', "Keyboard Shortcuts");
registerOpenGlobalKeybindingsActionDisposables.add(registerAction2(class extends Action2 {
constructor() {
super({
id,
title: { value: nls.localize('openGlobalKeybindings', "Open Keyboard Shortcuts"), original: 'Open Keyboard Shortcuts' },
shortTitle,
category,
icon: preferencesOpenSettingsIcon,
keybinding: {
when: null,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyS)
},
menu: [
{ id: MenuId.CommandPalette },
{
id: MenuId.EditorTitle,
when: ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.keybindingsResource.toString()),
group: 'navigation',
order: 1,
},
{
id: MenuId.GlobalActivity,
group: '2_configuration',
order: 3
}
]
});
}
run(accessor: ServicesAccessor, args: string | undefined) {
const query = typeof args === 'string' ? args : undefined;
return accessor.get(IPreferencesService).openGlobalKeybindingSettings(false, { query });
}
}));
registerOpenGlobalKeybindingsActionDisposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
command: {
const id = 'workbench.action.openGlobalKeybindings';
this._register(registerAction2(class extends Action2 {
constructor() {
super({
id,
title: shortTitle,
},
group: '2_configuration',
order: 3
}));
};
registerOpenGlobalKeybindingsAction();
this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenGlobalKeybindingsAction()));
title: { value: nls.localize('openGlobalKeybindings', "Open Keyboard Shortcuts"), original: 'Open Keyboard Shortcuts' },
shortTitle: nls.localize('keyboardShortcuts', "Keyboard Shortcuts"),
category,
icon: preferencesOpenSettingsIcon,
keybinding: {
when: null,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyS)
},
menu: [
{ id: MenuId.CommandPalette },
{
id: MenuId.EditorTitle,
when: ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.keybindingsResource.toString()),
group: 'navigation',
order: 1,
},
{
id: MenuId.GlobalActivity,
group: '2_configuration',
order: 3
}
]
});
}
run(accessor: ServicesAccessor, args: string | undefined) {
const query = typeof args === 'string' ? args : undefined;
return accessor.get(IPreferencesService).openGlobalKeybindingSettings(false, { query });
}
}));
this._register(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
command: {
id,
title: nls.localize('keyboardShortcuts', "Keyboard Shortcuts"),
},
group: '2_configuration',
order: 3
}));
registerAction2(class extends Action2 {
constructor() {
super({
Expand Down