|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
7 |
| -import { Disposable } from 'vs/base/common/lifecycle'; |
| 7 | +import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle'; |
8 | 8 | import { Schemas } from 'vs/base/common/network';
|
9 | 9 | import { isObject } from 'vs/base/common/types';
|
10 | 10 | import { URI } from 'vs/base/common/uri';
|
@@ -244,25 +244,32 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
|
244 | 244 | return accessor.get(IPreferencesService).openRawDefaultSettings();
|
245 | 245 | }
|
246 | 246 | });
|
247 |
| - registerAction2(class extends Action2 { |
248 |
| - constructor() { |
249 |
| - super({ |
250 |
| - id: '_workbench.openUserSettingsEditor', |
251 |
| - title: OPEN_SETTINGS2_ACTION_TITLE, |
252 |
| - icon: preferencesOpenSettingsIcon, |
253 |
| - menu: [{ |
254 |
| - id: MenuId.EditorTitle, |
255 |
| - when: ContextKeyExpr.and(ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.settingsResource.toString()), ContextKeyExpr.not('isInDiffEditor')), |
256 |
| - group: 'navigation', |
257 |
| - order: 1 |
258 |
| - }] |
259 |
| - }); |
260 |
| - } |
261 |
| - run(accessor: ServicesAccessor, args: IOpenSettingsActionOptions) { |
262 |
| - args = sanitizeOpenSettingsArgs(args); |
263 |
| - return accessor.get(IPreferencesService).openUserSettings({ jsonEditor: false, ...args }); |
264 |
| - } |
265 |
| - }); |
| 247 | + |
| 248 | + const registerOpenUserSettingsEditorFromJsonActionDisposable = this._register(new MutableDisposable()); |
| 249 | + const registerOpenUserSettingsEditorFromJsonAction = () => { |
| 250 | + registerOpenUserSettingsEditorFromJsonActionDisposable.value = registerAction2(class extends Action2 { |
| 251 | + constructor() { |
| 252 | + super({ |
| 253 | + id: '_workbench.openUserSettingsEditor', |
| 254 | + title: OPEN_SETTINGS2_ACTION_TITLE, |
| 255 | + icon: preferencesOpenSettingsIcon, |
| 256 | + menu: [{ |
| 257 | + id: MenuId.EditorTitle, |
| 258 | + when: ContextKeyExpr.and(ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.settingsResource.toString()), ContextKeyExpr.not('isInDiffEditor')), |
| 259 | + group: 'navigation', |
| 260 | + order: 1 |
| 261 | + }] |
| 262 | + }); |
| 263 | + } |
| 264 | + run(accessor: ServicesAccessor, args: IOpenSettingsActionOptions) { |
| 265 | + args = sanitizeOpenSettingsArgs(args); |
| 266 | + return accessor.get(IPreferencesService).openUserSettings({ jsonEditor: false, ...args }); |
| 267 | + } |
| 268 | + }); |
| 269 | + }; |
| 270 | + registerOpenUserSettingsEditorFromJsonAction(); |
| 271 | + this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenUserSettingsEditorFromJsonAction())); |
| 272 | + |
266 | 273 | registerAction2(class extends Action2 {
|
267 | 274 | constructor() {
|
268 | 275 | super({
|
@@ -728,34 +735,39 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
|
728 | 735 | private registerKeybindingsActions() {
|
729 | 736 | const that = this;
|
730 | 737 | const category = { value: nls.localize('preferences', "Preferences"), original: 'Preferences' };
|
731 |
| - registerAction2(class extends Action2 { |
732 |
| - constructor() { |
733 |
| - super({ |
734 |
| - id: 'workbench.action.openGlobalKeybindings', |
735 |
| - title: { value: nls.localize('openGlobalKeybindings', "Open Keyboard Shortcuts"), original: 'Open Keyboard Shortcuts' }, |
736 |
| - category, |
737 |
| - icon: preferencesOpenSettingsIcon, |
738 |
| - keybinding: { |
739 |
| - when: null, |
740 |
| - weight: KeybindingWeight.WorkbenchContrib, |
741 |
| - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyS) |
742 |
| - }, |
743 |
| - menu: [ |
744 |
| - { id: MenuId.CommandPalette }, |
745 |
| - { |
746 |
| - id: MenuId.EditorTitle, |
747 |
| - when: ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.keybindingsResource.toString()), |
748 |
| - group: 'navigation', |
749 |
| - order: 1, |
750 |
| - } |
751 |
| - ] |
752 |
| - }); |
753 |
| - } |
754 |
| - run(accessor: ServicesAccessor, args: string | undefined) { |
755 |
| - const query = typeof args === 'string' ? args : undefined; |
756 |
| - return accessor.get(IPreferencesService).openGlobalKeybindingSettings(false, { query }); |
757 |
| - } |
758 |
| - }); |
| 738 | + const registerOpenGlobalKeybindingsActionDisposable = this._register(new MutableDisposable()); |
| 739 | + const registerOpenGlobalKeybindingsAction = () => { |
| 740 | + registerOpenGlobalKeybindingsActionDisposable.value = registerAction2(class extends Action2 { |
| 741 | + constructor() { |
| 742 | + super({ |
| 743 | + id: 'workbench.action.openGlobalKeybindings', |
| 744 | + title: { value: nls.localize('openGlobalKeybindings', "Open Keyboard Shortcuts"), original: 'Open Keyboard Shortcuts' }, |
| 745 | + category, |
| 746 | + icon: preferencesOpenSettingsIcon, |
| 747 | + keybinding: { |
| 748 | + when: null, |
| 749 | + weight: KeybindingWeight.WorkbenchContrib, |
| 750 | + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyS) |
| 751 | + }, |
| 752 | + menu: [ |
| 753 | + { id: MenuId.CommandPalette }, |
| 754 | + { |
| 755 | + id: MenuId.EditorTitle, |
| 756 | + when: ResourceContextKey.Resource.isEqualTo(that.userDataProfileService.currentProfile.keybindingsResource.toString()), |
| 757 | + group: 'navigation', |
| 758 | + order: 1, |
| 759 | + } |
| 760 | + ] |
| 761 | + }); |
| 762 | + } |
| 763 | + run(accessor: ServicesAccessor, args: string | undefined) { |
| 764 | + const query = typeof args === 'string' ? args : undefined; |
| 765 | + return accessor.get(IPreferencesService).openGlobalKeybindingSettings(false, { query }); |
| 766 | + } |
| 767 | + }); |
| 768 | + }; |
| 769 | + registerOpenGlobalKeybindingsAction(); |
| 770 | + this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => registerOpenGlobalKeybindingsAction())); |
759 | 771 | MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
760 | 772 | command: {
|
761 | 773 | id: 'workbench.action.openGlobalKeybindings',
|
|
0 commit comments