debug: Handle disposable result of createAndFillInActionBarActions
#76419
This commit is contained in:
parent
f91bd1869c
commit
b57a00bd28
|
@ -31,6 +31,7 @@ import { createAndFillInActionBarActions, MenuEntryActionViewItem } from 'vs/pla
|
|||
import { IMenu, IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { FocusSessionAction } from 'vs/workbench/contrib/debug/browser/debugActions';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
|
||||
const DEBUG_TOOLBAR_POSITION_KEY = 'debug.actionswidgetposition';
|
||||
const DEBUG_TOOLBAR_Y_KEY = 'debug.actionswidgety';
|
||||
|
@ -54,6 +55,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
|
|||
private activeActions: IAction[];
|
||||
private updateScheduler: RunOnceScheduler;
|
||||
private debugToolBarMenu: IMenu;
|
||||
private disposeOnUpdate: IDisposable;
|
||||
|
||||
private isVisible: boolean;
|
||||
private isBuilt: boolean;
|
||||
|
@ -105,12 +107,17 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
|
|||
return this.hide();
|
||||
}
|
||||
|
||||
const actions = DebugToolBar.getActions(this.debugToolBarMenu, this.debugService, this.instantiationService);
|
||||
const { actions, disposable } = DebugToolBar.getActions(this.debugToolBarMenu, this.debugService, this.instantiationService);
|
||||
if (!arrays.equals(actions, this.activeActions, (first, second) => first.id === second.id)) {
|
||||
this.actionBar.clear();
|
||||
this.actionBar.push(actions, { icon: true, label: false });
|
||||
this.activeActions = actions;
|
||||
}
|
||||
if (this.disposeOnUpdate) {
|
||||
dispose(this.disposeOnUpdate);
|
||||
}
|
||||
this.disposeOnUpdate = disposable;
|
||||
|
||||
this.show();
|
||||
}, 20));
|
||||
|
||||
|
@ -257,14 +264,17 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
|
|||
dom.hide(this.$el);
|
||||
}
|
||||
|
||||
public static getActions(menu: IMenu, debugService: IDebugService, instantiationService: IInstantiationService): IAction[] {
|
||||
public static getActions(menu: IMenu, debugService: IDebugService, instantiationService: IInstantiationService): { actions: IAction[], disposable: IDisposable } {
|
||||
const actions: IAction[] = [];
|
||||
createAndFillInActionBarActions(menu, undefined, actions, () => false);
|
||||
const disposable = createAndFillInActionBarActions(menu, undefined, actions, () => false);
|
||||
if (debugService.getViewModel().isMultiSessionView()) {
|
||||
actions.push(instantiationService.createInstance(FocusSessionAction, FocusSessionAction.ID, FocusSessionAction.LABEL));
|
||||
}
|
||||
|
||||
return actions.filter(a => !(a instanceof Separator)); // do not render separators for now
|
||||
return {
|
||||
actions: actions.filter(a => !(a instanceof Separator)), // do not render separators for now
|
||||
disposable
|
||||
};
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
@ -274,5 +284,8 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
|
|||
this.$el.remove();
|
||||
delete this.$el;
|
||||
}
|
||||
if (this.disposeOnUpdate) {
|
||||
dispose(this.disposeOnUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ export class DebugViewlet extends ViewContainerViewlet {
|
|||
private breakpointView: ViewletPanel;
|
||||
private panelListeners = new Map<string, IDisposable>();
|
||||
private debugToolBarMenu: IMenu;
|
||||
private disposeOnTitleUpdate: IDisposable;
|
||||
|
||||
constructor(
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
|
@ -114,7 +115,14 @@ export class DebugViewlet extends ViewContainerViewlet {
|
|||
this.debugToolBarMenu = this.menuService.createMenu(MenuId.DebugToolBar, this.contextKeyService);
|
||||
this._register(this.debugToolBarMenu);
|
||||
}
|
||||
return DebugToolBar.getActions(this.debugToolBarMenu, this.debugService, this.instantiationService);
|
||||
|
||||
const { actions, disposable } = DebugToolBar.getActions(this.debugToolBarMenu, this.debugService, this.instantiationService);
|
||||
if (this.disposeOnTitleUpdate) {
|
||||
dispose(this.disposeOnTitleUpdate);
|
||||
}
|
||||
this.disposeOnTitleUpdate = disposable;
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
get showInitialDebugActions(): boolean {
|
||||
|
|
Loading…
Reference in a new issue