Skip to content

Commit af0c01b

Browse files
committed
Short title for command contribution.
1 parent 29c6157 commit af0c01b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/vs/platform/actions/common/actions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export type Icon = { dark?: URI; light?: URI; } | ThemeIcon;
4141
export interface ICommandAction {
4242
id: string;
4343
title: string | ICommandActionTitle;
44+
shortTitle?: string | ICommandActionTitle;
4445
category?: string | ILocalizedString;
4546
tooltip?: string;
4647
icon?: Icon;
@@ -179,6 +180,7 @@ export class MenuId {
179180
export interface IMenuActionOptions {
180181
arg?: any;
181182
shouldForwardArgs?: boolean;
183+
renderShortTitle?: boolean;
182184
}
183185

184186
export interface IMenu extends IDisposable {
@@ -388,7 +390,9 @@ export class MenuItemAction implements IAction {
388390
@ICommandService private _commandService: ICommandService
389391
) {
390392
this.id = item.id;
391-
this.label = typeof item.title === 'string' ? item.title : item.title.value;
393+
this.label = options?.renderShortTitle && item.shortTitle
394+
? (typeof item.shortTitle === 'string' ? item.shortTitle : item.shortTitle.value)
395+
: (typeof item.title === 'string' ? item.title : item.title.value);
392396
this.tooltip = item.tooltip ?? '';
393397
this.enabled = !item.precondition || contextKeyService.contextMatchesRules(item.precondition);
394398
this.checked = false;

src/vs/workbench/api/common/menusExtensionPoint.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ namespace schema {
438438
export interface IUserFriendlyCommand {
439439
command: string;
440440
title: string | ILocalizedString;
441+
shortTitle?: string | ILocalizedString;
441442
enablement?: string;
442443
category?: string | ILocalizedString;
443444
icon?: IUserFriendlyIcon;
@@ -457,6 +458,9 @@ namespace schema {
457458
if (!isValidLocalizedString(command.title, collector, 'title')) {
458459
return false;
459460
}
461+
if (command.shortTitle && !isValidLocalizedString(command.shortTitle, collector, 'shortTitle')) {
462+
return false;
463+
}
460464
if (command.enablement && typeof command.enablement !== 'string') {
461465
collector.error(localize('optstring', "property `{0}` can be omitted or must be of type `string`", 'precondition'));
462466
return false;
@@ -510,6 +514,10 @@ namespace schema {
510514
description: localize('vscode.extension.contributes.commandType.title', 'Title by which the command is represented in the UI'),
511515
type: 'string'
512516
},
517+
shortTitle: {
518+
description: localize('vscode.extension.contributes.commandType.shortTitle', 'Short title by which the command is represented in the UI'),
519+
type: 'string'
520+
},
513521
category: {
514522
description: localize('vscode.extension.contributes.commandType.category', '(Optional) Category string by the command is grouped in the UI'),
515523
type: 'string'
@@ -567,7 +575,7 @@ commandsExtensionPoint.setHandler(extensions => {
567575
return;
568576
}
569577

570-
const { icon, enablement, category, title, command } = userFriendlyCommand;
578+
const { icon, enablement, category, title, shortTitle, command } = userFriendlyCommand;
571579

572580
let absoluteIcon: { dark: URI; light?: URI; } | ThemeIcon | undefined;
573581
if (icon) {
@@ -588,6 +596,7 @@ commandsExtensionPoint.setHandler(extensions => {
588596
bucket.push({
589597
id: command,
590598
title,
599+
shortTitle,
591600
category,
592601
precondition: ContextKeyExpr.deserialize(enablement),
593602
icon: absoluteIcon

src/vs/workbench/contrib/notebook/browser/notebookEditorToolbar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class NotebookEditorToolbar extends Disposable {
164164
this.domNode.style.display = 'none';
165165
} else {
166166
this._notebookLeftToolbar.setActions([], []);
167-
const groups = this._notebookGlobalActionsMenu.getActions({ shouldForwardArgs: true });
167+
const groups = this._notebookGlobalActionsMenu.getActions({ shouldForwardArgs: true, renderShortTitle: true });
168168
this.domNode.style.display = 'flex';
169169
const primaryLeftGroups = groups.filter(group => /^navigation/.test(group[0]));
170170
let primaryActions: IAction[] = [];

0 commit comments

Comments
 (0)