Skip to content

Commit f05eb4a

Browse files
authored
Clean up duplicate menu registration in cell run toolbar (microsoft#161124)
1 parent c126d94 commit f05eb4a

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export class BetweenCellToolbar extends CellPart {
3131
@IInstantiationService instantiationService: IInstantiationService,
3232
) {
3333
super();
34-
3534
this._betweenCellToolbar = this._register(instantiationService.createInstance(MenuWorkbenchToolBar, this._bottomCellToolbarContainer, this._notebookEditor.creationOptions.menuIds.cellInsertToolbar, {
3635
actionViewItemProvider: action => {
3736
if (action instanceof MenuItemAction) {

src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import { NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CEL
2626
export class RunToolbar extends CellPart {
2727
private toolbar!: WorkbenchToolBar;
2828

29+
private primaryMenu: IMenu;
30+
private secondaryMenu: IMenu;
31+
2932
constructor(
3033
readonly notebookEditor: INotebookEditorDelegate,
3134
readonly contextKeyService: IContextKeyService,
@@ -38,18 +41,17 @@ export class RunToolbar extends CellPart {
3841
) {
3942
super();
4043

41-
const menu = this._register(menuService.createMenu(this.notebookEditor.creationOptions.menuIds.cellExecutePrimary!, contextKeyService));
42-
const secondaryMenu = this._register(menuService.createMenu(this.notebookEditor.creationOptions.menuIds.cellExecuteToolbar, contextKeyService));
43-
// TODO@roblourens what does secondaryMenu actually do? where/when is it rendered?
44+
this.primaryMenu = this._register(menuService.createMenu(this.notebookEditor.creationOptions.menuIds.cellExecutePrimary!, contextKeyService));
45+
this.secondaryMenu = this._register(menuService.createMenu(this.notebookEditor.creationOptions.menuIds.cellExecuteToolbar, contextKeyService));
4446
this.createRunCellToolbar(runButtonContainer, cellContainer, contextKeyService);
4547
const updateActions = () => {
46-
const actions = this.getCellToolbarActions(menu);
48+
const actions = this.getCellToolbarActions(this.primaryMenu);
4749
const primary = actions.primary[0]; // Only allow one primary action
4850
this.toolbar.setActions(primary ? [primary] : []);
4951
};
5052
updateActions();
51-
this._register(menu.onDidChange(updateActions));
52-
this._register(secondaryMenu.onDidChange(updateActions));
53+
this._register(this.primaryMenu.onDidChange(updateActions));
54+
this._register(this.secondaryMenu.onDidChange(updateActions));
5355
this._register(this.notebookEditor.notebookOptions.onDidChangeOptions(updateActions));
5456
}
5557

@@ -86,14 +88,12 @@ export class RunToolbar extends CellPart {
8688
actionViewItemProvider: _action => {
8789
actionViewItemDisposables.clear();
8890

89-
const primaryMenu = actionViewItemDisposables.add(this.menuService.createMenu(this.notebookEditor.creationOptions.menuIds.cellExecutePrimary!, contextKeyService));
90-
const primary = this.getCellToolbarActions(primaryMenu).primary[0];
91+
const primary = this.getCellToolbarActions(this.primaryMenu).primary[0];
9192
if (!(primary instanceof MenuItemAction)) {
9293
return undefined;
9394
}
9495

95-
const menu = actionViewItemDisposables.add(this.menuService.createMenu(this.notebookEditor.creationOptions.menuIds.cellExecuteToolbar, contextKeyService));
96-
const secondary = this.getCellToolbarActions(menu).secondary;
96+
const secondary = this.getCellToolbarActions(this.secondaryMenu).secondary;
9797
if (!secondary.length) {
9898
return undefined;
9999
}

0 commit comments

Comments
 (0)