Skip to content

Commit 2617166

Browse files
authored
Make ActionList take a list of menu items directly (microsoft#166750)
We don't need the extra indirection of calling `toMenuItems`
1 parent 61e40d1 commit 2617166

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/vs/platform/actionWidget/browser/actionList.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,20 @@ class ActionItemRenderer<T extends IListMenuItem<IActionItem>> implements IListR
140140

141141
export class ActionList<T extends IActionItem> extends Disposable {
142142

143-
readonly domNode: HTMLElement;
143+
public readonly domNode: HTMLElement;
144+
144145
private readonly _list: List<IListMenuItem<IActionItem>>;
145146

146147
private readonly _actionLineHeight = 24;
147148
private readonly _headerLineHeight = 26;
148149

149150
private readonly _allMenuItems: IListMenuItem<IActionItem>[];
150151

151-
private focusCondition(element: IListMenuItem<IActionItem>): boolean {
152-
return !element.disabled && element.kind === ActionListItemKind.Action;
153-
}
154-
155152
constructor(
156153
user: string,
157-
items: readonly T[],
158-
showHeaders: boolean,
154+
items: IListMenuItem<T>[],
159155
private readonly _delegate: IRenderDelegate,
160156
resolver: IActionKeybindingResolver | undefined,
161-
toMenuItems: (inputActions: readonly T[], showHeaders: boolean) => IListMenuItem<T>[],
162157
@IContextViewService private readonly _contextViewService: IContextViewService,
163158
@IKeybindingService private readonly _keybindingService: IKeybindingService
164159
) {
@@ -194,11 +189,15 @@ export class ActionList<T extends IActionItem> extends Disposable {
194189
this._register(this._list.onDidChangeFocus(() => this._list.domFocus()));
195190
this._register(this._list.onDidChangeSelection(e => this.onListSelection(e)));
196191

197-
this._allMenuItems = toMenuItems(items, showHeaders);
192+
this._allMenuItems = items;
198193
this._list.splice(0, this._list.length, this._allMenuItems);
199194
this.focusNext();
200195
}
201196

197+
private focusCondition(element: IListMenuItem<IActionItem>): boolean {
198+
return !element.disabled && element.kind === ActionListItemKind.Action;
199+
}
200+
202201
hide(didCancel?: boolean): void {
203202
this._delegate.onHide(didCancel);
204203
this._contextViewService.hideContextView();

src/vs/platform/actionWidget/browser/actionWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ActionWidgetService extends Disposable implements IActionWidgetService {
8989

9090
this._currentShowingContext = { user, toMenuItems, delegate, actions, anchor, container, options, resolver };
9191

92-
const list = this._instantiationService.createInstance(ActionList, user, actionsToShow, true, delegate, resolver, toMenuItems);
92+
const list = this._instantiationService.createInstance(ActionList, user, toMenuItems(actionsToShow, true), delegate, resolver);
9393
this.contextViewService.showContextView({
9494
getAnchor: () => anchor,
9595
render: (container: HTMLElement) => {

0 commit comments

Comments
 (0)