Skip to content

Commit f345453

Browse files
author
Benjamin Pasero
committed
Command categories are repeated in many places (fix microsoft#106019)
1 parent 382f9e5 commit f345453

49 files changed

Lines changed: 241 additions & 248 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/vs/workbench/api/browser/viewsExtensionPoint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { ViewletRegistry, Extensions as ViewletExtensions, ShowViewletAction } f
2626
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
2727
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
2828
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
29-
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
29+
import { IWorkbenchActionRegistry, Extensions as ActionExtensions, CATEGORIES } from 'vs/workbench/common/actions';
3030
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
3131
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
3232
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
@@ -408,7 +408,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
408408
registry.registerWorkbenchAction(
409409
SyncActionDescriptor.create(OpenCustomViewletAction, id, localize('showViewlet', "Show {0}", title)),
410410
`View: Show ${title}`,
411-
localize('view', "View")
411+
CATEGORIES.View.value
412412
);
413413
}
414414

src/vs/workbench/browser/actions/developerActions.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
2727
import { ILogService } from 'vs/platform/log/common/log';
2828
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
2929
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
30-
31-
const developerCategory = { value: nls.localize({ key: 'developer', comment: ['A developer on Code itself or someone diagnosing issues in Code'] }, "Developer"), original: 'Developer' };
30+
import { CATEGORIES } from 'vs/workbench/common/actions';
3231

3332
class InspectContextKeysAction extends Action2 {
3433

3534
constructor() {
3635
super({
3736
id: 'workbench.action.inspectContextKeys',
3837
title: { value: nls.localize('inspect context keys', "Inspect Context Keys"), original: 'Inspect Context Keys' },
39-
category: developerCategory,
38+
category: CATEGORIES.Developer,
4039
f1: true
4140
});
4241
}
@@ -98,7 +97,7 @@ class ToggleScreencastModeAction extends Action2 {
9897
super({
9998
id: 'workbench.action.toggleScreencastMode',
10099
title: { value: nls.localize('toggle screencast mode', "Toggle Screencast Mode"), original: 'Toggle Screencast Mode' },
101-
category: developerCategory,
100+
category: CATEGORIES.Developer,
102101
f1: true
103102
});
104103
}
@@ -243,7 +242,7 @@ class LogStorageAction extends Action2 {
243242
super({
244243
id: 'workbench.action.logStorage',
245244
title: { value: nls.localize({ key: 'logStorage', comment: ['A developer only action to log the contents of the storage for the current window.'] }, "Log Storage Database Contents"), original: 'Log Storage Database Contents' },
246-
category: developerCategory,
245+
category: CATEGORIES.Developer,
247246
f1: true
248247
});
249248
}
@@ -259,7 +258,7 @@ class LogWorkingCopiesAction extends Action2 {
259258
super({
260259
id: 'workbench.action.logWorkingCopies',
261260
title: { value: nls.localize({ key: 'logWorkingCopies', comment: ['A developer only action to log the working copies that exist.'] }, "Log Working Copies"), original: 'Log Working Copies' },
262-
category: developerCategory,
261+
category: CATEGORIES.Developer,
263262
f1: true
264263
});
265264
}

src/vs/workbench/browser/actions/helpActions.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { KeyChord, KeyMod, KeyCode } from 'vs/base/common/keyCodes';
1414
import { IProductService } from 'vs/platform/product/common/productService';
1515
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1616
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
17-
18-
const helpCategory = { value: nls.localize('help', "Help"), original: 'Help' };
17+
import { CATEGORIES } from 'vs/workbench/common/actions';
1918

2019
class KeybindingsReferenceAction extends Action2 {
2120

@@ -26,7 +25,7 @@ class KeybindingsReferenceAction extends Action2 {
2625
super({
2726
id: KeybindingsReferenceAction.ID,
2827
title: { value: nls.localize('keybindingsReference', "Keyboard Shortcuts Reference"), original: 'Keyboard Shortcuts Reference' },
29-
category: helpCategory,
28+
category: CATEGORIES.Help,
3029
f1: true,
3130
keybinding: {
3231
weight: KeybindingWeight.WorkbenchContrib,
@@ -56,7 +55,7 @@ class OpenDocumentationUrlAction extends Action2 {
5655
super({
5756
id: OpenDocumentationUrlAction.ID,
5857
title: { value: nls.localize('openDocumentationUrl', "Documentation"), original: 'Documentation' },
59-
category: helpCategory,
58+
category: CATEGORIES.Help,
6059
f1: true
6160
});
6261
}
@@ -80,7 +79,7 @@ class OpenIntroductoryVideosUrlAction extends Action2 {
8079
super({
8180
id: OpenIntroductoryVideosUrlAction.ID,
8281
title: { value: nls.localize('openIntroductoryVideosUrl', "Introductory Videos"), original: 'Introductory Videos' },
83-
category: helpCategory,
82+
category: CATEGORIES.Help,
8483
f1: true
8584
});
8685
}
@@ -104,7 +103,7 @@ class OpenTipsAndTricksUrlAction extends Action2 {
104103
super({
105104
id: OpenTipsAndTricksUrlAction.ID,
106105
title: { value: nls.localize('openTipsAndTricksUrl', "Tips and Tricks"), original: 'Tips and Tricks' },
107-
category: helpCategory,
106+
category: CATEGORIES.Help,
108107
f1: true
109108
});
110109
}
@@ -128,7 +127,7 @@ class OpenNewsletterSignupUrlAction extends Action2 {
128127
super({
129128
id: OpenNewsletterSignupUrlAction.ID,
130129
title: { value: nls.localize('newsletterSignup', "Signup for the VS Code Newsletter"), original: 'Signup for the VS Code Newsletter' },
131-
category: helpCategory,
130+
category: CATEGORIES.Help,
132131
f1: true
133132
});
134133
}
@@ -153,7 +152,7 @@ class OpenTwitterUrlAction extends Action2 {
153152
super({
154153
id: OpenTwitterUrlAction.ID,
155154
title: { value: nls.localize('openTwitterUrl', "Join Us on Twitter"), original: 'Join Us on Twitter' },
156-
category: helpCategory,
155+
category: CATEGORIES.Help,
157156
f1: true
158157
});
159158
}
@@ -177,7 +176,7 @@ class OpenRequestFeatureUrlAction extends Action2 {
177176
super({
178177
id: OpenRequestFeatureUrlAction.ID,
179178
title: { value: nls.localize('openUserVoiceUrl', "Search Feature Requests"), original: 'Search Feature Requests' },
180-
category: helpCategory,
179+
category: CATEGORIES.Help,
181180
f1: true
182181
});
183182
}
@@ -201,7 +200,7 @@ class OpenLicenseUrlAction extends Action2 {
201200
super({
202201
id: OpenLicenseUrlAction.ID,
203202
title: { value: nls.localize('openLicenseUrl', "View License"), original: 'View License' },
204-
category: helpCategory,
203+
category: CATEGORIES.Help,
205204
f1: true
206205
});
207206
}
@@ -230,7 +229,7 @@ class OpenPrivacyStatementUrlAction extends Action2 {
230229
super({
231230
id: OpenPrivacyStatementUrlAction.ID,
232231
title: { value: nls.localize('openPrivacyStatement', "Privacy Statement"), original: 'Privacy Statement' },
233-
category: helpCategory,
232+
category: CATEGORIES.Help,
234233
f1: true
235234
});
236235
}

src/vs/workbench/browser/actions/layoutActions.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
77
import { Registry } from 'vs/platform/registry/common/platform';
88
import { Action } from 'vs/base/common/actions';
99
import { SyncActionDescriptor, MenuId, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
10-
import { IWorkbenchActionRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/actions';
10+
import { IWorkbenchActionRegistry, Extensions as WorkbenchExtensions, CATEGORIES } from 'vs/workbench/common/actions';
1111
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
1212
import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
1313
import { IEditorGroupsService, GroupOrientation } from 'vs/workbench/services/editor/common/editorGroupsService';
@@ -30,7 +30,6 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
3030
import { Codicon } from 'vs/base/common/codicons';
3131

3232
const registry = Registry.as<IWorkbenchActionRegistry>(WorkbenchExtensions.WorkbenchActions);
33-
const viewCategory = { value: nls.localize('view', "View"), original: 'View' };
3433

3534
// --- Close Side Bar
3635

@@ -40,7 +39,7 @@ class CloseSidebarAction extends Action2 {
4039
super({
4140
id: 'workbench.action.closeSidebar',
4241
title: { value: nls.localize('closeSidebar', "Close Side Bar"), original: 'Close Side Bar' },
43-
category: viewCategory,
42+
category: CATEGORIES.View,
4443
f1: true
4544
});
4645
}
@@ -65,7 +64,7 @@ export class ToggleActivityBarVisibilityAction extends Action2 {
6564
super({
6665
id: ToggleActivityBarVisibilityAction.ID,
6766
title: { value: ToggleActivityBarVisibilityAction.LABEL, original: 'Toggle Activity Bar Visibility' },
68-
category: viewCategory,
67+
category: CATEGORIES.View,
6968
f1: true
7069
});
7170
}
@@ -103,7 +102,7 @@ class ToggleCenteredLayout extends Action2 {
103102
super({
104103
id: ToggleCenteredLayout.ID,
105104
title: { value: nls.localize('toggleCenteredLayout', "Toggle Centered Layout"), original: 'Toggle Centered Layout' },
106-
category: viewCategory,
105+
category: CATEGORIES.View,
107106
f1: true
108107
});
109108
}
@@ -164,7 +163,7 @@ export class ToggleEditorLayoutAction extends Action {
164163
}
165164
}
166165

167-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleEditorLayoutAction, { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_0, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_0 } }), 'View: Toggle Vertical/Horizontal Editor Layout', viewCategory.value);
166+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleEditorLayoutAction, { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_0, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_0 } }), 'View: Toggle Vertical/Horizontal Editor Layout', CATEGORIES.View.value);
168167

169168
MenuRegistry.appendMenuItem(MenuId.MenubarLayoutMenu, {
170169
group: 'z_flip',
@@ -205,7 +204,7 @@ export class ToggleSidebarPositionAction extends Action {
205204
}
206205
}
207206

208-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleSidebarPositionAction), 'View: Toggle Side Bar Position', viewCategory.value);
207+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleSidebarPositionAction), 'View: Toggle Side Bar Position', CATEGORIES.View.value);
209208

210209
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
211210
group: '3_workbench_layout_move',
@@ -246,7 +245,7 @@ export class ToggleEditorVisibilityAction extends Action {
246245
}
247246
}
248247

249-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleEditorVisibilityAction), 'View: Toggle Editor Area Visibility', viewCategory.value);
248+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleEditorVisibilityAction), 'View: Toggle Editor Area Visibility', CATEGORIES.View.value);
250249

251250
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
252251
group: '2_workbench_layout',
@@ -277,7 +276,7 @@ export class ToggleSidebarVisibilityAction extends Action {
277276
}
278277
}
279278

280-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleSidebarVisibilityAction, { primary: KeyMod.CtrlCmd | KeyCode.KEY_B }), 'View: Toggle Side Bar Visibility', viewCategory.value);
279+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleSidebarVisibilityAction, { primary: KeyMod.CtrlCmd | KeyCode.KEY_B }), 'View: Toggle Side Bar Visibility', CATEGORIES.View.value);
281280

282281
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
283282
group: '2_appearance',
@@ -322,7 +321,7 @@ export class ToggleStatusbarVisibilityAction extends Action {
322321
}
323322
}
324323

325-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleStatusbarVisibilityAction), 'View: Toggle Status Bar Visibility', viewCategory.value);
324+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleStatusbarVisibilityAction), 'View: Toggle Status Bar Visibility', CATEGORIES.View.value);
326325

327326
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
328327
group: '2_workbench_layout',
@@ -363,7 +362,7 @@ registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleTabsVisibilityA
363362
primary: undefined,
364363
mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_W, },
365364
linux: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_W, }
366-
}), 'View: Toggle Tab Visibility', viewCategory.value);
365+
}), 'View: Toggle Tab Visibility', CATEGORIES.View.value);
367366

368367
// --- Toggle Zen Mode
369368

@@ -385,7 +384,7 @@ class ToggleZenMode extends Action {
385384
}
386385
}
387386

388-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleZenMode, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_Z) }), 'View: Toggle Zen Mode', viewCategory.value);
387+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleZenMode, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_Z) }), 'View: Toggle Zen Mode', CATEGORIES.View.value);
389388

390389
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
391390
group: '1_toggle_view',
@@ -446,7 +445,7 @@ export class ToggleMenuBarAction extends Action {
446445
}
447446

448447
if (isWindows || isLinux || isWeb) {
449-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleMenuBarAction), 'View: Toggle Menu Bar', viewCategory.value);
448+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ToggleMenuBarAction), 'View: Toggle Menu Bar', CATEGORIES.View.value);
450449
}
451450

452451
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
@@ -479,7 +478,7 @@ export class ResetViewLocationsAction extends Action {
479478
}
480479
}
481480

482-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ResetViewLocationsAction), 'View: Reset View Locations', viewCategory.value);
481+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ResetViewLocationsAction), 'View: Reset View Locations', CATEGORIES.View.value);
483482

484483
// --- Toggle View with Command
485484
export abstract class ToggleViewAction extends Action {
@@ -626,7 +625,7 @@ export class MoveViewAction extends Action {
626625
}
627626
}
628627

629-
registry.registerWorkbenchAction(SyncActionDescriptor.from(MoveViewAction), 'View: Move View', viewCategory.value);
628+
registry.registerWorkbenchAction(SyncActionDescriptor.from(MoveViewAction), 'View: Move View', CATEGORIES.View.value);
630629

631630
// --- Move Focused View with Command
632631
export class MoveFocusedViewAction extends Action {
@@ -749,7 +748,7 @@ export class MoveFocusedViewAction extends Action {
749748
}
750749
}
751750

752-
registry.registerWorkbenchAction(SyncActionDescriptor.from(MoveFocusedViewAction), 'View: Move Focused View', viewCategory.value, FocusedViewContext.notEqualsTo(''));
751+
registry.registerWorkbenchAction(SyncActionDescriptor.from(MoveFocusedViewAction), 'View: Move Focused View', CATEGORIES.View.value, FocusedViewContext.notEqualsTo(''));
753752

754753
// --- Reset View Location with Command
755754
export class ResetFocusedViewLocationAction extends Action {
@@ -791,7 +790,7 @@ export class ResetFocusedViewLocationAction extends Action {
791790
}
792791
}
793792

794-
registry.registerWorkbenchAction(SyncActionDescriptor.from(ResetFocusedViewLocationAction), 'View: Reset Focused View Location', viewCategory.value, FocusedViewContext.notEqualsTo(''));
793+
registry.registerWorkbenchAction(SyncActionDescriptor.from(ResetFocusedViewLocationAction), 'View: Reset Focused View Location', CATEGORIES.View.value, FocusedViewContext.notEqualsTo(''));
795794

796795

797796
// --- Resize View
@@ -865,5 +864,5 @@ export class DecreaseViewSizeAction extends BaseResizeViewAction {
865864
}
866865
}
867866

868-
registry.registerWorkbenchAction(SyncActionDescriptor.from(IncreaseViewSizeAction, undefined), 'View: Increase Current View Size', viewCategory.value);
869-
registry.registerWorkbenchAction(SyncActionDescriptor.from(DecreaseViewSizeAction, undefined), 'View: Decrease Current View Size', viewCategory.value);
867+
registry.registerWorkbenchAction(SyncActionDescriptor.from(IncreaseViewSizeAction, undefined), 'View: Increase Current View Size', CATEGORIES.View.value);
868+
registry.registerWorkbenchAction(SyncActionDescriptor.from(DecreaseViewSizeAction, undefined), 'View: Decrease Current View Size', CATEGORIES.View.value);

src/vs/workbench/browser/actions/navigationActions.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
1313
import { IViewlet } from 'vs/workbench/common/viewlet';
1414
import { IPanel } from 'vs/workbench/common/panel';
1515
import { Action2, MenuId, registerAction2, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
16-
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
16+
import { IWorkbenchActionRegistry, Extensions, CATEGORIES } from 'vs/workbench/common/actions';
1717
import { Direction } from 'vs/base/browser/ui/grid/grid';
1818
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
1919
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
@@ -284,14 +284,13 @@ class GoHomeContributor implements IWorkbenchContribution {
284284
}
285285

286286
const actionsRegistry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
287-
const viewCategory = nls.localize('view', "View");
288-
289-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateUpAction, undefined), 'View: Navigate to the View Above', viewCategory);
290-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateDownAction, undefined), 'View: Navigate to the View Below', viewCategory);
291-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateLeftAction, undefined), 'View: Navigate to the View on the Left', viewCategory);
292-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateRightAction, undefined), 'View: Navigate to the View on the Right', viewCategory);
293-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusNextPart, { primary: KeyCode.F6 }), 'View: Focus Next Part', viewCategory);
294-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusPreviousPart, { primary: KeyMod.Shift | KeyCode.F6 }), 'View: Focus Previous Part', viewCategory);
287+
288+
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateUpAction, undefined), 'View: Navigate to the View Above', CATEGORIES.View.value);
289+
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateDownAction, undefined), 'View: Navigate to the View Below', CATEGORIES.View.value);
290+
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateLeftAction, undefined), 'View: Navigate to the View on the Left', CATEGORIES.View.value);
291+
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateRightAction, undefined), 'View: Navigate to the View on the Right', CATEGORIES.View.value);
292+
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusNextPart, { primary: KeyCode.F6 }), 'View: Focus Next Part', CATEGORIES.View.value);
293+
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusPreviousPart, { primary: KeyMod.Shift | KeyCode.F6 }), 'View: Focus Previous Part', CATEGORIES.View.value);
295294

296295
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
297296
workbenchRegistry.registerWorkbenchContribution(GoHomeContributor, LifecyclePhase.Ready);

0 commit comments

Comments
 (0)