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

Commands display both translated names and original names in command palette. #142524

Merged
merged 4 commits into from Feb 9, 2022
Merged
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
20 changes: 10 additions & 10 deletions src/vs/workbench/browser/parts/editor/editorCommands.ts
Expand Up @@ -1027,7 +1027,7 @@ function registerSplitEditorInGroupCommands(): void {
constructor() {
super({
id: SPLIT_EDITOR_IN_GROUP,
title: localize('splitEditorInGroup', "Split Editor in Group"),
title: { value: localize('splitEditorInGroup', "Split Editor in Group"), original: 'Split Editor in Group' },
category: CATEGORIES.View,
precondition: ActiveEditorCanSplitInGroupContext,
f1: true,
Expand Down Expand Up @@ -1073,7 +1073,7 @@ function registerSplitEditorInGroupCommands(): void {
constructor() {
super({
id: JOIN_EDITOR_IN_GROUP,
title: localize('joinEditorInGroup', "Join Editor in Group"),
title: { value: localize('joinEditorInGroup', "Join Editor in Group"), original: 'Join Editor in Group' },
category: CATEGORIES.View,
precondition: SideBySideEditorActiveContext,
f1: true,
Expand All @@ -1093,7 +1093,7 @@ function registerSplitEditorInGroupCommands(): void {
constructor() {
super({
id: TOGGLE_SPLIT_EDITOR_IN_GROUP,
title: localize('toggleJoinEditorInGroup', "Toggle Split Editor in Group"),
title: { value: localize('toggleJoinEditorInGroup', "Toggle Split Editor in Group"), original: 'Toggle Split Editor in Group' },
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext),
f1: true
Expand All @@ -1115,7 +1115,7 @@ function registerSplitEditorInGroupCommands(): void {
constructor() {
super({
id: TOGGLE_SPLIT_EDITOR_IN_GROUP_LAYOUT,
title: localize('toggleSplitEditorInGroupLayout', "Toggle Split Editor in Group Layout"),
title: { value: localize('toggleSplitEditorInGroupLayout', "Toggle Split Editor in Group Layout"), original: 'Toggle Split Editor in Group Layout' },
category: CATEGORIES.View,
precondition: SideBySideEditorActiveContext,
f1: true
Expand Down Expand Up @@ -1143,7 +1143,7 @@ function registerFocusSideEditorsCommands(): void {
constructor() {
super({
id: FOCUS_FIRST_SIDE_EDITOR,
title: localize('focusLeftSideEditor', "Focus First Side in Active Editor"),
title: { value: localize('focusLeftSideEditor', "Focus First Side in Active Editor"), original: 'Focus First Side in Active Editor' },
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
f1: true
Expand All @@ -1166,7 +1166,7 @@ function registerFocusSideEditorsCommands(): void {
constructor() {
super({
id: FOCUS_SECOND_SIDE_EDITOR,
title: localize('focusRightSideEditor', "Focus Second Side in Active Editor"),
title: { value: localize('focusRightSideEditor', "Focus Second Side in Active Editor"), original: 'Focus Second Side in Active Editor' },
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
f1: true
Expand All @@ -1189,7 +1189,7 @@ function registerFocusSideEditorsCommands(): void {
constructor() {
super({
id: FOCUS_OTHER_SIDE_EDITOR,
title: localize('focusOtherSideEditor', "Focus Other Side in Active Editor"),
title: { value: localize('focusOtherSideEditor', "Focus Other Side in Active Editor"), original: 'Focus Other Side in Active Editor' },
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
f1: true
Expand Down Expand Up @@ -1254,7 +1254,7 @@ function registerOtherEditorCommands(): void {
constructor() {
super({
id: TOGGLE_LOCK_GROUP_COMMAND_ID,
title: localize('toggleEditorGroupLock', "Toggle Editor Group Lock"),
title: { value: localize('toggleEditorGroupLock', "Toggle Editor Group Lock"), original: 'Toggle Editor Group Lock' },
category: CATEGORIES.View,
precondition: MultipleEditorGroupsContext,
f1: true
Expand All @@ -1269,7 +1269,7 @@ function registerOtherEditorCommands(): void {
constructor() {
super({
id: LOCK_GROUP_COMMAND_ID,
title: localize('lockEditorGroup', "Lock Editor Group"),
title: { value: localize('lockEditorGroup', "Lock Editor Group"), original: 'Lock Editor Group' },
category: CATEGORIES.View,
precondition: ContextKeyExpr.and(MultipleEditorGroupsContext, ActiveEditorGroupLockedContext.toNegated()),
f1: true
Expand All @@ -1284,7 +1284,7 @@ function registerOtherEditorCommands(): void {
constructor() {
super({
id: UNLOCK_GROUP_COMMAND_ID,
title: localize('unlockEditorGroup', "Unlock Editor Group"),
title: { value: localize('unlockEditorGroup', "Unlock Editor Group"), original: 'Unlock Editor Group' },
precondition: ContextKeyExpr.and(MultipleEditorGroupsContext, ActiveEditorGroupLockedContext),
category: CATEGORIES.View,
f1: true
Expand Down
42 changes: 20 additions & 22 deletions src/vs/workbench/browser/parts/panel/panelActions.ts
Expand Up @@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { Action } from 'vs/base/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncActionDescriptor, MenuId, MenuRegistry, registerAction2, Action2, IAction2Options } from 'vs/platform/actions/common/actions';
import { SyncActionDescriptor, MenuId, MenuRegistry, registerAction2, Action2, IAction2Options, ICommandActionTitle } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions as WorkbenchExtensions, CATEGORIES } from 'vs/workbench/common/actions';
import { IWorkbenchLayoutService, PanelAlignment, Parts, Position, positionToString } from 'vs/workbench/services/layout/browser/layoutService';
import { ActivityAction, ToggleCompositePinnedAction, ICompositeBar } from 'vs/workbench/browser/parts/compositeBarActions';
Expand Down Expand Up @@ -89,44 +89,42 @@ const AlignPanelActionId = {
interface PanelActionConfig<T> {
id: string;
when: ContextKeyExpression;
alias: string;
label: string;
title: ICommandActionTitle;
shortLabel: string;
value: T;
}

function createPanelActionConfig<T>(id: string, alias: string, label: string, shortLabel: string, value: T, when: ContextKeyExpression): PanelActionConfig<T> {
function createPanelActionConfig<T>(id: string, title: ICommandActionTitle, shortLabel: string, value: T, when: ContextKeyExpression): PanelActionConfig<T> {
return {
id,
alias,
label,
title,
shortLabel,
value,
when,
};
}

function createPositionPanelActionConfig(id: string, alias: string, label: string, shortLabel: string, position: Position): PanelActionConfig<Position> {
return createPanelActionConfig<Position>(id, alias, label, shortLabel, position, PanelPositionContext.notEqualsTo(positionToString(position)));
function createPositionPanelActionConfig(id: string, title: ICommandActionTitle, shortLabel: string, position: Position): PanelActionConfig<Position> {
return createPanelActionConfig<Position>(id, title, shortLabel, position, PanelPositionContext.notEqualsTo(positionToString(position)));
}

function createAlignmentPanelActionConfig(id: string, alias: string, label: string, shortLabel: string, alignment: PanelAlignment): PanelActionConfig<PanelAlignment> {
return createPanelActionConfig<PanelAlignment>(id, alias, label, shortLabel, alignment, PanelAlignmentContext.notEqualsTo(alignment));
function createAlignmentPanelActionConfig(id: string, title: ICommandActionTitle, shortLabel: string, alignment: PanelAlignment): PanelActionConfig<PanelAlignment> {
return createPanelActionConfig<PanelAlignment>(id, title, shortLabel, alignment, PanelAlignmentContext.notEqualsTo(alignment));
}


export const PositionPanelActionConfigs: PanelActionConfig<Position>[] = [
createPositionPanelActionConfig(PositionPanelActionId.LEFT, 'View: Move Panel Left', localize('positionPanelLeft', 'Move Panel Left'), localize('positionPanelLeftShort', "Left"), Position.LEFT),
createPositionPanelActionConfig(PositionPanelActionId.RIGHT, 'View: Move Panel Right', localize('positionPanelRight', 'Move Panel Right'), localize('positionPanelRightShort', "Right"), Position.RIGHT),
createPositionPanelActionConfig(PositionPanelActionId.BOTTOM, 'View: Move Panel To Bottom', localize('positionPanelBottom', 'Move Panel To Bottom'), localize('positionPanelBottomShort', "Bottom"), Position.BOTTOM),
createPositionPanelActionConfig(PositionPanelActionId.LEFT, { value: localize('positionPanelLeft', 'Move Panel Left'), original: 'Move Panel Left' }, localize('positionPanelLeftShort', "Left"), Position.LEFT),
createPositionPanelActionConfig(PositionPanelActionId.RIGHT, { value: localize('positionPanelRight', 'Move Panel Right'), original: 'Move Panel Right' }, localize('positionPanelRightShort', "Right"), Position.RIGHT),
createPositionPanelActionConfig(PositionPanelActionId.BOTTOM, { value: localize('positionPanelBottom', 'Move Panel To Bottom'), original: 'Move Panel To Bottom' }, localize('positionPanelBottomShort', "Bottom"), Position.BOTTOM),
];


export const AlignPanelActionConfigs: PanelActionConfig<PanelAlignment>[] = [
createAlignmentPanelActionConfig(AlignPanelActionId.LEFT, 'View: Set Panel Alignment to Left', localize('alignPanelLeft', 'Set Panel Alignment to Left'), localize('alignPanelLeftShort', "Left"), 'left'),
createAlignmentPanelActionConfig(AlignPanelActionId.RIGHT, 'View: Set Panel Alignment to Right', localize('alignPanelRight', 'Set Panel Alignment to Right'), localize('alignPanelRightShort', "Right"), 'right'),
createAlignmentPanelActionConfig(AlignPanelActionId.CENTER, 'View: Set Panel Alignment to Center', localize('alignPanelCenter', 'Set Panel Alignment to Center'), localize('alignPanelCenterShort', "Center"), 'center'),
createAlignmentPanelActionConfig(AlignPanelActionId.JUSTIFY, 'View: Set Panel Alignment to Justify', localize('alignPanelJustify', 'Set Panel Alignment to Justify'), localize('alignPanelJustifyShort', "Justify"), 'justify'),
const AlignPanelActionConfigs: PanelActionConfig<PanelAlignment>[] = [
createAlignmentPanelActionConfig(AlignPanelActionId.LEFT, { value: localize('alignPanelLeft', 'Set Panel Alignment to Left'), original: 'Set Panel Alignment to Left' }, localize('alignPanelLeftShort', "Left"), 'left'),
createAlignmentPanelActionConfig(AlignPanelActionId.RIGHT, { value: localize('alignPanelRight', 'Set Panel Alignment to Right'), original: 'Set Panel Alignment to Right' }, localize('alignPanelRightShort', "Right"), 'right'),
createAlignmentPanelActionConfig(AlignPanelActionId.CENTER, { value: localize('alignPanelCenter', 'Set Panel Alignment to Center'), original: 'Set Panel Alignment to Center' }, localize('alignPanelCenterShort', "Center"), 'center'),
createAlignmentPanelActionConfig(AlignPanelActionId.JUSTIFY, { value: localize('alignPanelJustify', 'Set Panel Alignment to Justify'), original: 'Set Panel Alignment to Justify' }, localize('alignPanelJustifyShort', "Justify"), 'justify'),
];

const positionByActionId = new Map(PositionPanelActionConfigs.map(config => [config.id, config.value]));
Expand All @@ -153,13 +151,13 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
});

PositionPanelActionConfigs.forEach(positionPanelAction => {
const { id, label, shortLabel, value, when } = positionPanelAction;
const { id, title, shortLabel, value, when } = positionPanelAction;

registerAction2(class extends Action2 {
constructor() {
super({
id,
title: label,
title,
category: CATEGORIES.View,
f1: true
});
Expand Down Expand Up @@ -188,12 +186,12 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
});

AlignPanelActionConfigs.forEach(alignPanelAction => {
const { id, label, shortLabel, value, when } = alignPanelAction;
const { id, title, shortLabel, value, when } = alignPanelAction;
registerAction2(class extends Action2 {
constructor() {
super({
id,
title: label,
title: title,
category: CATEGORIES.View,
toggled: when.negate(),
f1: true
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/panel/panelPart.ts
Expand Up @@ -942,7 +942,7 @@ export class PanelPart extends BasePanelPart {
...PositionPanelActionConfigs
// show the contextual menu item if it is not in that position
.filter(({ when }) => this.contextKeyService.contextMatchesRules(when))
.map(({ id, label }) => this.instantiationService.createInstance(SetPanelPositionAction, id, label)),
.map(({ id, title }) => this.instantiationService.createInstance(SetPanelPositionAction, id, title.value)),
this.instantiationService.createInstance(TogglePanelAction, TogglePanelAction.ID, localize('hidePanel', "Hide Panel"))
]);
}
Expand Down
Expand Up @@ -214,7 +214,7 @@ class ToggleRenderAction extends Action2 {
constructor(id: string, title: string | ICommandActionTitle, precondition: ContextKeyExpression | undefined, toggled: ContextKeyExpression | undefined, order: number, private readonly toggleOutputs?: boolean, private readonly toggleMetadata?: boolean) {
super({
id: id,
title: title,
title,
precondition: precondition,
menu: [{
id: MenuId.EditorTitle,
Expand Down
Expand Up @@ -559,7 +559,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
},
category,
f1: true,
title: nls.localize('settings.focusSearch', "Focus Settings Search")
title: { value: nls.localize('settings.focusSearch', "Focus Settings Search"), original: 'Focus Settings Search' }
});
}

Expand All @@ -578,7 +578,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
},
category,
f1: true,
title: nls.localize('settings.clearResults', "Clear Settings Search Results")
title: { value: nls.localize('settings.clearResults', "Clear Settings Search Results"), original: 'Clear Settings Search Results' }
});
}

Expand Down Expand Up @@ -665,7 +665,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
when: CONTEXT_SETTINGS_ROW_FOCUS
}],
category,
title: nls.localize('settings.focusSettingsTOC', "Focus Settings Table of Contents")
title: { value: nls.localize('settings.focusSettingsTOC', "Focus Settings Table of Contents"), original: 'Focus Settings Table of Contents' }
});
}

Expand Down Expand Up @@ -716,7 +716,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
},
f1: true,
category,
title: nls.localize('settings.showContextMenu', "Show Setting Context Menu")
title: { value: nls.localize('settings.showContextMenu', "Show Setting Context Menu"), original: 'Show Setting Context Menu' }
});
}

Expand All @@ -740,7 +740,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
},
f1: true,
category,
title: nls.localize('settings.focusLevelUp', "Move Focus Up One Level")
title: { value: nls.localize('settings.focusLevelUp', "Move Focus Up One Level"), original: 'Move Focus Up One Level' }
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/browser/scmViewPane.ts
Expand Up @@ -1507,7 +1507,7 @@ abstract class SetSortKeyAction extends ViewAction<SCMViewPane> {
constructor(private sortKey: ViewModelSortKey, title: string) {
super({
id: `workbench.scm.action.setSortKey.${sortKey}`,
title: title,
title,
viewId: VIEW_PANE_ID,
f1: false,
toggled: ContextKeys.ViewModelSortKey.isEqualTo(sortKey),
Expand Down
Expand Up @@ -347,7 +347,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: SelectColorThemeCommandId,
title: localize('selectTheme.label', "Color Theme"),
title: { value: localize('selectTheme.label', "Color Theme"), original: 'Color Theme' },
category: CATEGORIES.Preferences,
f1: true,
keybinding: {
Expand Down Expand Up @@ -389,7 +389,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: SelectFileIconThemeCommandId,
title: localize('selectIconTheme.label', "File Icon Theme"),
title: { value: localize('selectIconTheme.label', "File Icon Theme"), original: 'File Icon Theme' },
category: CATEGORIES.Preferences,
f1: true
});
Expand Down Expand Up @@ -424,7 +424,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: SelectProductIconThemeCommandId,
title: localize('selectProductIconTheme.label', "Product Icon Theme"),
title: { value: localize('selectProductIconTheme.label', "Product Icon Theme"), original: 'Product Icon Theme' },
category: CATEGORIES.Preferences,
f1: true
});
Expand Down Expand Up @@ -528,7 +528,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'workbench.action.generateColorTheme',
title: localize('generateColorTheme.label', "Generate Color Theme From Current Settings"),
title: { value: localize('generateColorTheme.label', "Generate Color Theme From Current Settings"), original: 'Generate Color Theme From Current Settings' },
category: CATEGORIES.Developer,
f1: true
});
Expand Down
Expand Up @@ -38,7 +38,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'workbench.action.openWalkthrough',
title: localize('miGetStarted', "Get Started"),
title: { value: localize('miGetStarted', "Get Started"), original: 'Get Started' },
category: localize('help', "Help"),
f1: true,
menu: {
Expand Down Expand Up @@ -106,7 +106,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'welcome.goBack',
title: localize('welcome.goBack', "Go Back"),
title: { value: localize('welcome.goBack', "Go Back"), original: 'Go Back' },
category,
keybinding: {
weight: KeybindingWeight.EditorContrib,
Expand Down Expand Up @@ -176,7 +176,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'welcome.showAllWalkthroughs',
title: localize('welcome.showAllWalkthroughs', "Open Walkthrough..."),
title: { value: localize('welcome.showAllWalkthroughs', "Open Walkthrough..."), original: 'Open Walkthrough...' },
category,
f1: true,
});
Expand Down
Expand Up @@ -27,7 +27,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'welcome.showNewFileEntries',
title: localize('welcome.newFile', "New File..."),
title: { value: localize('welcome.newFile', "New File..."), original: 'New File...' },
category,
f1: true,
keybinding: {
Expand Down
Expand Up @@ -257,7 +257,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'extension.bisect.next',
title: localize('title.isBad', "Continue Extension Bisect"),
title: { value: localize('title.isBad', "Continue Extension Bisect"), original: 'Continue Extension Bisect' },
category: localize('help', "Help"),
f1: true,
precondition: ExtensionBisectUi.ctxIsBisectActive
Expand Down Expand Up @@ -344,7 +344,7 @@ registerAction2(class extends Action2 {
constructor() {
super({
id: 'extension.bisect.stop',
title: localize('title.stop', "Stop Extension Bisect"),
title: { value: localize('title.stop', "Stop Extension Bisect"), original: 'Stop Extension Bisect' },
category: localize('help', "Help"),
f1: true,
precondition: ExtensionBisectUi.ctxIsBisectActive
Expand Down