Skip to content

Commit

Permalink
fix #85671
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 27, 2019
1 parent 4766da6 commit 453e750
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/vs/platform/actions/common/menuService.ts
Expand Up @@ -5,7 +5,7 @@

import { Emitter, Event } from 'vs/base/common/event';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { IMenu, IMenuActionOptions, IMenuItem, IMenuService, isIMenuItem, ISubmenuItem, MenuId, MenuItemAction, MenuRegistry, SubmenuItemAction } from 'vs/platform/actions/common/actions';
import { IMenu, IMenuActionOptions, IMenuItem, IMenuService, isIMenuItem, ISubmenuItem, MenuId, MenuItemAction, MenuRegistry, SubmenuItemAction, ILocalizedString } from 'vs/platform/actions/common/actions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr, IContextKeyService, IContextKeyChangeEvent } from 'vs/platform/contextkey/common/contextkey';

Expand Down Expand Up @@ -133,7 +133,7 @@ class Menu implements IMenu {
}
}

private static _compareMenuItems(a: IMenuItem, b: IMenuItem): number {
private static _compareMenuItems(a: IMenuItem | ISubmenuItem, b: IMenuItem | ISubmenuItem): number {

let aGroup = a.group;
let bGroup = b.group;
Expand Down Expand Up @@ -171,8 +171,15 @@ class Menu implements IMenu {
}

// sort on titles
const aTitle = typeof a.command.title === 'string' ? a.command.title : a.command.title.value;
const bTitle = typeof b.command.title === 'string' ? b.command.title : b.command.title.value;
return aTitle.localeCompare(bTitle);
return Menu._compareTitles(
isIMenuItem(a) ? a.command.title : a.title,
isIMenuItem(b) ? b.command.title : b.title
);
}

private static _compareTitles(a: string | ILocalizedString, b: string | ILocalizedString) {
const aStr = typeof a === 'string' ? a : a.value;
const bStr = typeof b === 'string' ? b : b.value;
return aStr.localeCompare(bStr);
}
}

0 comments on commit 453e750

Please sign in to comment.