Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/vs/editor/browser/services/hoverService/hoverWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import './hover.css';
import { DisposableStore, MutableDisposable } from '../../../../base/common/lifecycle.js';
import { DisposableStore, MutableDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
import { Event, Emitter } from '../../../../base/common/event.js';
import * as dom from '../../../../base/browser/dom.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
Expand Down Expand Up @@ -165,7 +165,7 @@ export class HoverWidget extends Widget implements IHoverWidget {
{ codeBlockFontFamily: this._configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily }
);

const { element } = mdRenderer.render(markdown, {
const { element, dispose } = mdRenderer.render(markdown, {
actionHandler: {
callback: (content) => this._linkHandler(content),
disposables: this._messageListeners
Expand All @@ -178,6 +178,7 @@ export class HoverWidget extends Widget implements IHoverWidget {
}
});
contentsElement.appendChild(element);
this._register(toDisposable(dispose));
}
rowElement.appendChild(contentsElement);
this._hover.contentsDomNode.appendChild(rowElement);
Expand All @@ -188,15 +189,15 @@ export class HoverWidget extends Widget implements IHoverWidget {
options.actions.forEach(action => {
const keybinding = this._keybindingService.lookupKeybinding(action.commandId);
const keybindingLabel = keybinding ? keybinding.getLabel() : null;
HoverAction.render(actionsElement, {
this._register(HoverAction.render(actionsElement, {
label: action.label,
commandId: action.commandId,
run: e => {
action.run(e);
this.dispose();
},
iconClass: action.iconClass
}, keybindingLabel);
}, keybindingLabel));
});
statusBarElement.appendChild(actionsElement);
this._hover.containerDomNode.appendChild(statusBarElement);
Expand Down
18 changes: 12 additions & 6 deletions src/vs/workbench/browser/parts/titlebar/menubarControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ export class CustomMenubarControl extends MenubarControl {
}

private readonly reinstallDisposables = this._register(new DisposableStore());
private readonly updateActionsDisposables = this._register(new DisposableStore());
private setupCustomMenubar(firstTime: boolean): void {
// If there is no container, we cannot setup the menubar
if (!this.container) {
Expand Down Expand Up @@ -620,7 +621,7 @@ export class CustomMenubarControl extends MenubarControl {
}

// Update the menu actions
const updateActions = (menuActions: readonly IAction[], target: IAction[], topLevelTitle: string) => {
const updateActions = (menuActions: readonly IAction[], target: IAction[], topLevelTitle: string, store: DisposableStore) => {
target.splice(0);

for (const menuItem of menuActions) {
Expand All @@ -636,7 +637,7 @@ export class CustomMenubarControl extends MenubarControl {

if (menuItem instanceof SubmenuItemAction) {
const submenuActions: SubmenuAction[] = [];
updateActions(menuItem.actions, submenuActions, topLevelTitle);
updateActions(menuItem.actions, submenuActions, topLevelTitle, store);

if (submenuActions.length > 0) {
target.push(new SubmenuAction(menuItem.id, mnemonicMenuLabel(title), submenuActions));
Expand All @@ -646,7 +647,7 @@ export class CustomMenubarControl extends MenubarControl {
title = menuItem.item.toggled.mnemonicTitle ?? menuItem.item.toggled.title ?? title;
}

const newAction = new Action(menuItem.id, mnemonicMenuLabel(title), menuItem.class, menuItem.enabled, () => this.commandService.executeCommand(menuItem.id));
const newAction = store.add(new Action(menuItem.id, mnemonicMenuLabel(title), menuItem.class, menuItem.enabled, () => this.commandService.executeCommand(menuItem.id)));
newAction.tooltip = menuItem.tooltip;
newAction.checked = menuItem.checked;
target.push(newAction);
Expand All @@ -667,20 +668,24 @@ export class CustomMenubarControl extends MenubarControl {
for (const title of Object.keys(this.topLevelTitles)) {
const menu = this.menus[title];
if (firstTime && menu) {
const menuChangedDisposable = this.reinstallDisposables.add(new DisposableStore());
this.reinstallDisposables.add(menu.onDidChange(() => {
if (!this.focusInsideMenubar) {
const actions: IAction[] = [];
updateActions(this.toActionsArray(menu), actions, title);
menuChangedDisposable.clear();
updateActions(this.toActionsArray(menu), actions, title, menuChangedDisposable);
this.menubar?.updateMenu({ actions, label: mnemonicMenuLabel(this.topLevelTitles[title]) });
}
}));

// For the file menu, we need to update if the web nav menu updates as well
if (menu === this.menus.File) {
const webMenuChangedDisposable = this.reinstallDisposables.add(new DisposableStore());
this.reinstallDisposables.add(this.webNavigationMenu.onDidChange(() => {
if (!this.focusInsideMenubar) {
const actions: IAction[] = [];
updateActions(this.toActionsArray(menu), actions, title);
webMenuChangedDisposable.clear();
updateActions(this.toActionsArray(menu), actions, title, webMenuChangedDisposable);
this.menubar?.updateMenu({ actions, label: mnemonicMenuLabel(this.topLevelTitles[title]) });
}
}));
Expand All @@ -689,7 +694,8 @@ export class CustomMenubarControl extends MenubarControl {

const actions: IAction[] = [];
if (menu) {
updateActions(this.toActionsArray(menu), actions, title);
this.updateActionsDisposables.clear();
updateActions(this.toActionsArray(menu), actions, title, this.updateActionsDisposables);
}

if (this.menubar) {
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/contrib/timeline/browser/timelinePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,10 @@ class TimelineTreeRenderer implements ITreeRenderer<TreeElement, FuzzyScore, Tim
}
}

disposeElement(element: ITreeNode<TreeElement, FuzzyScore>, index: number, templateData: TimelineElementTemplate, height: number | undefined): void {
templateData.actionBar.actionRunner.dispose();
}

disposeTemplate(template: TimelineElementTemplate): void {
template.dispose();
}
Expand Down
Loading