Skip to content

Commit

Permalink
Add descriptions for commands #209511
Browse files Browse the repository at this point in the history
  • Loading branch information
benibenj committed Apr 4, 2024
1 parent 1e765ad commit 37bf996
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
22 changes: 14 additions & 8 deletions src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { localize, localize2 } from 'vs/nls';
import { ILocalizedString, localize, localize2 } from 'vs/nls';
import { MenuId, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
Expand Down Expand Up @@ -447,12 +447,13 @@ registerAction2(ToggleStatusbarVisibilityAction);

abstract class AbstractSetShowTabsAction extends Action2 {

constructor(private readonly settingName: string, private readonly value: string, title: ICommandActionTitle, id: string, precondition: ContextKeyExpression) {
constructor(private readonly settingName: string, private readonly value: string, title: ICommandActionTitle, id: string, precondition: ContextKeyExpression, description: string | ILocalizedString | undefined) {
super({
id,
title,
category: Categories.View,
precondition,
metadata: description ? { description } : undefined,
f1: true
});
}
Expand All @@ -472,7 +473,7 @@ export class HideEditorTabsAction extends AbstractSetShowTabsAction {
constructor() {
const precondition = ContextKeyExpr.and(ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.NONE).negate(), InEditorZenModeContext.negate())!;
const title = localize2('hideEditorTabs', 'Hide Editor Tabs');
super(LayoutSettings.EDITOR_TABS_MODE, EditorTabsMode.NONE, title, HideEditorTabsAction.ID, precondition);
super(LayoutSettings.EDITOR_TABS_MODE, EditorTabsMode.NONE, title, HideEditorTabsAction.ID, precondition, localize2('hideEditorTabsDescription', "Hide Tab Bar"));
}
}

Expand All @@ -483,7 +484,7 @@ export class ZenHideEditorTabsAction extends AbstractSetShowTabsAction {
constructor() {
const precondition = ContextKeyExpr.and(ContextKeyExpr.equals(`config.${ZenModeSettings.SHOW_TABS}`, EditorTabsMode.NONE).negate(), InEditorZenModeContext)!;
const title = localize2('hideEditorTabsZenMode', 'Hide Editor Tabs in Zen Mode');
super(ZenModeSettings.SHOW_TABS, EditorTabsMode.NONE, title, ZenHideEditorTabsAction.ID, precondition);
super(ZenModeSettings.SHOW_TABS, EditorTabsMode.NONE, title, ZenHideEditorTabsAction.ID, precondition, localize2('hideEditorTabsZenModeDescription', "Hide Tab Bar in Zen Mode"));
}
}

Expand All @@ -497,7 +498,7 @@ export class ShowMultipleEditorTabsAction extends AbstractSetShowTabsAction {
const precondition = ContextKeyExpr.and(ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.MULTIPLE).negate(), InEditorZenModeContext.negate())!;
const title = localize2('showMultipleEditorTabs', 'Show Multiple Editor Tabs');

super(LayoutSettings.EDITOR_TABS_MODE, EditorTabsMode.MULTIPLE, title, ShowMultipleEditorTabsAction.ID, precondition);
super(LayoutSettings.EDITOR_TABS_MODE, EditorTabsMode.MULTIPLE, title, ShowMultipleEditorTabsAction.ID, precondition, localize2('showMultipleEditorTabsDescription', "Show Tab Bar with multiple tabs"));
}
}

Expand All @@ -509,7 +510,7 @@ export class ZenShowMultipleEditorTabsAction extends AbstractSetShowTabsAction {
const precondition = ContextKeyExpr.and(ContextKeyExpr.equals(`config.${ZenModeSettings.SHOW_TABS}`, EditorTabsMode.MULTIPLE).negate(), InEditorZenModeContext)!;
const title = localize2('showMultipleEditorTabsZenMode', 'Show Multiple Editor Tabs in Zen Mode');

super(ZenModeSettings.SHOW_TABS, EditorTabsMode.MULTIPLE, title, ZenShowMultipleEditorTabsAction.ID, precondition);
super(ZenModeSettings.SHOW_TABS, EditorTabsMode.MULTIPLE, title, ZenShowMultipleEditorTabsAction.ID, precondition, localize2('showMultipleEditorTabsZenModeDescription', "Show Tab Bar in Zen Mode"));
}
}

Expand All @@ -523,7 +524,7 @@ export class ShowSingleEditorTabAction extends AbstractSetShowTabsAction {
const precondition = ContextKeyExpr.and(ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.SINGLE).negate(), InEditorZenModeContext.negate())!;
const title = localize2('showSingleEditorTab', 'Show Single Editor Tab');

super(LayoutSettings.EDITOR_TABS_MODE, EditorTabsMode.SINGLE, title, ShowSingleEditorTabAction.ID, precondition);
super(LayoutSettings.EDITOR_TABS_MODE, EditorTabsMode.SINGLE, title, ShowSingleEditorTabAction.ID, precondition, localize2('showSingleEditorTabDescription', "Show Tab Bar with one Tab"));
}
}

Expand All @@ -535,7 +536,7 @@ export class ZenShowSingleEditorTabAction extends AbstractSetShowTabsAction {
const precondition = ContextKeyExpr.and(ContextKeyExpr.equals(`config.${ZenModeSettings.SHOW_TABS}`, EditorTabsMode.SINGLE).negate(), InEditorZenModeContext)!;
const title = localize2('showSingleEditorTabZenMode', 'Show Single Editor Tab in Zen Mode');

super(ZenModeSettings.SHOW_TABS, EditorTabsMode.SINGLE, title, ZenShowSingleEditorTabAction.ID, precondition);
super(ZenModeSettings.SHOW_TABS, EditorTabsMode.SINGLE, title, ZenShowSingleEditorTabAction.ID, precondition, localize2('showSingleEditorTabZenModeDescription', "Show Tab Bar in Zen Mode with one Tab"));
}
}

Expand Down Expand Up @@ -576,6 +577,7 @@ export class EditorActionsTitleBarAction extends Action2 {
title: localize2('moveEditorActionsToTitleBar', "Move Editor Actions to Title Bar"),
category: Categories.View,
precondition: ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`, EditorActionsLocation.TITLEBAR).negate(),
metadata: { description: localize2('moveEditorActionsToTitleBarDescription', "Move Editor Actions from the tab bar to the title bar") },
f1: true
});
}
Expand All @@ -602,6 +604,7 @@ export class EditorActionsDefaultAction extends Action2 {
ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`, EditorActionsLocation.DEFAULT).negate(),
ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.NONE).negate(),
),
metadata: { description: localize2('moveEditorActionsToTabBarDescription', "Move Editor Actions from the title bar to the tab bar") },
f1: true
});
}
Expand All @@ -625,6 +628,7 @@ export class HideEditorActionsAction extends Action2 {
title: localize2('hideEditorActons', "Hide Editor Actions"),
category: Categories.View,
precondition: ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`, EditorActionsLocation.HIDDEN).negate(),
metadata: { description: localize2('hideEditorActonsDescription', "Hide Editor Actions in the tab and title bar") },
f1: true
});
}
Expand All @@ -648,6 +652,7 @@ export class ShowEditorActionsAction extends Action2 {
title: localize2('showEditorActons', "Show Editor Actions"),
category: Categories.View,
precondition: ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`, EditorActionsLocation.HIDDEN),
metadata: { description: localize2('showEditorActonsDescription', "Make Editor Actions visible.") },
f1: true
});
}
Expand Down Expand Up @@ -678,6 +683,7 @@ registerAction2(class extends Action2 {
title: localize2('toggleSeparatePinnedEditorTabs', "Separate Pinned Editor Tabs"),
category: Categories.View,
precondition: ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.MULTIPLE),
metadata: { description: localize2('toggleSeparatePinnedEditorTabsDescription', "Toggle whether pinned editor tabs are shown on a separate row above unpinned tabs.") },
f1: true
});
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/browser/actions/listCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ registerAction2(class ToggleStickyScroll extends Action2 {
mnemonicTitle: localize({ key: 'mitoggleTreeStickyScroll', comment: ['&& denotes a mnemonic'] }, "&&Toggle Tree Sticky Scroll"),
},
category: 'View',
metadata: { description: localize('toggleTreeStickyScrollDescription', "Toggles Sticky Scroll widget at the top of tree structures such as the File Explorer and Debug variables View.") },
f1: true
});
}
Expand Down
9 changes: 5 additions & 4 deletions src/vs/workbench/browser/parts/titlebar/titlebarActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { localize, localize2 } from 'vs/nls';
import { ILocalizedString, localize, localize2 } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
Expand All @@ -19,11 +19,12 @@ import { CustomTitleBarVisibility, TitleBarSetting, TitlebarStyle } from 'vs/pla

class ToggleConfigAction extends Action2 {

constructor(private readonly section: string, title: string, order: number, mainWindowOnly: boolean) {
constructor(private readonly section: string, title: string, description: string | ILocalizedString | undefined, order: number, mainWindowOnly: boolean) {
const when = mainWindowOnly ? IsAuxiliaryWindowFocusedContext.toNegated() : ContextKeyExpr.true();
super({
id: `toggle.${section}`,
title,
metadata: description ? { description } : undefined,
toggled: ContextKeyExpr.equals(`config.${section}`, true),
menu: [
{
Expand Down Expand Up @@ -51,13 +52,13 @@ class ToggleConfigAction extends Action2 {

registerAction2(class ToggleCommandCenter extends ToggleConfigAction {
constructor() {
super(LayoutSettings.COMMAND_CENTER, localize('toggle.commandCenter', 'Command Center'), 1, false);
super(LayoutSettings.COMMAND_CENTER, localize('toggle.commandCenter', 'Command Center'), localize('toggle.commandCenterDescription', "Toggle visibility of the Command Center in title bar"), 1, false);
}
});

registerAction2(class ToggleLayoutControl extends ToggleConfigAction {
constructor() {
super('workbench.layoutControl.enabled', localize('toggle.layout', 'Layout Controls'), 2, true);
super('workbench.layoutControl.enabled', localize('toggle.layout', 'Layout Controls'), localize('toggle.layoutDescription', "Toggle visibility of the Layout Controls in title bar"), 2, true);
}
});

Expand Down

0 comments on commit 37bf996

Please sign in to comment.