Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relayout widget when menubars change #183209

Merged
merged 2 commits into from May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/vs/platform/actions/browser/toolbar.ts
Expand Up @@ -8,6 +8,7 @@ import { IToolBarOptions, ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { IAction, Separator, SubmenuAction, toAction, WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from 'vs/base/common/actions';
import { coalesceInPlace } from 'vs/base/common/arrays';
import { BugIndicatingError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
Expand Down Expand Up @@ -283,6 +284,9 @@ export interface IMenuWorkbenchToolBarOptions extends IWorkbenchToolBarOptions {
*/
export class MenuWorkbenchToolBar extends WorkbenchToolBar {

private readonly _onDidChangeMenuItems = this._store.add(new Emitter<this>());
readonly onDidChangeMenuItems: Event<this> = this._onDidChangeMenuItems.event;

constructor(
container: HTMLElement,
menuId: MenuId,
Expand All @@ -309,7 +313,10 @@ export class MenuWorkbenchToolBar extends WorkbenchToolBar {
super.setActions(primary, secondary);
};

this._store.add(menu.onDidChange(updateToolbar));
this._store.add(menu.onDidChange(() => {
updateToolbar();
this._onDidChangeMenuItems.fire(this);
}));
updateToolbar();
}

Expand Down
Expand Up @@ -290,6 +290,7 @@ export class InteractiveEditorWidget {
}
};
const statusToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.statusToolbar, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, workbenchToolbarOptions);
this._store.add(statusToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(statusToolbar);

// preview editors
Expand All @@ -301,6 +302,7 @@ export class InteractiveEditorWidget {
this._elements.message.tabIndex = 0;
this._elements.statusLabel.tabIndex = 0;
const markdownMessageToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.messageActions, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, workbenchToolbarOptions);
this._store.add(markdownMessageToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(markdownMessageToolbar);
}

Expand Down