polish remote menu separators

This commit is contained in:
Martin Aeschlimann
2021-04-14 15:04:30 +02:00
parent 5371ac58c4
commit cb8b3ce97b
@@ -291,29 +291,20 @@ export class RemoteStatusIndicator extends Disposable implements IWorkbenchContr
const actions = menu.getActions();
const items: (IQuickPickItem | IQuickPickSeparator)[] = [];
for (let actionGroup of actions) {
let lastCategoryName: string | undefined = undefined;
// group by category
const actionsByCategory: { [category: string]: MenuItemAction[] } = {};
const categories: string[] = [];
for (let actionGroup of actions) {
let hasGroupCategory = false;
for (let action of actionGroup[1]) {
if (action instanceof MenuItemAction) {
const category = getCategoryLabel(action) || '';
let list = actionsByCategory[category];
if (!list) {
actionsByCategory[category] = list = [];
categories.push(category);
if (!hasGroupCategory) {
const category = getCategoryLabel(action);
if (category !== lastCategoryName) {
items.push({ type: 'separator', label: category });
lastCategoryName = category;
}
hasGroupCategory = true;
}
list.push(action);
}
}
for (let category of categories) {
if (category) {
items.push({ type: 'separator', label: category });
} else {
items.push({ type: 'separator' });
}
for (let action of actionsByCategory[category]) {
let label = typeof action.item.title === 'string' ? action.item.title : action.item.title.value;
items.push({
type: 'item',