From 584893cfc0cd7992bf9216a73c0f7516e628f366 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 24 Apr 2020 10:50:31 +0200 Subject: [PATCH] Introduce an `inline` group to debug/callstack/context fixes #95887 --- .../contrib/debug/browser/callStackView.ts | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index 5faafeb0056..7a76d000134 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -21,7 +21,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c import { ViewPane } from 'vs/workbench/browser/parts/views/viewPaneContainer'; import { ILabelService } from 'vs/platform/label/common/label'; import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; -import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; +import { createAndFillInContextMenuActions, createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; import { ITreeRenderer, ITreeNode, ITreeContextMenuEvent, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree'; import { TreeResourceNavigator, WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService'; @@ -87,7 +87,7 @@ export class CallStackView extends ViewPane { private callStackItemType: IContextKey; private dataSource!: CallStackDataSource; private tree!: WorkbenchAsyncDataTree; - private contributedContextMenu: IMenu; + private menu: IMenu; private parentSessionToExpand = new Set(); private selectionNeedsUpdate = false; @@ -109,8 +109,8 @@ export class CallStackView extends ViewPane { super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService); this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService); - this.contributedContextMenu = menuService.createMenu(MenuId.DebugCallStackContext, contextKeyService); - this._register(this.contributedContextMenu); + this.menu = menuService.createMenu(MenuId.DebugCallStackContext, contextKeyService); + this._register(this.menu); // Create scheduler to prevent unnecessary flashing of tree when reacting to changes this.onCallStackChangeScheduler = new RunOnceScheduler(() => { @@ -172,7 +172,7 @@ export class CallStackView extends ViewPane { this.dataSource = new CallStackDataSource(this.debugService); this.tree = >this.instantiationService.createInstance(WorkbenchAsyncDataTree, 'CallStackView', treeContainer, new CallStackDelegate(), [ - new SessionsRenderer(this.instantiationService, this.debugService), + new SessionsRenderer(this.menu, this.instantiationService, this.debugService), new ThreadsRenderer(this.instantiationService), this.instantiationService.createInstance(StackFramesRenderer), new ErrorsRenderer(), @@ -378,12 +378,15 @@ export class CallStackView extends ViewPane { this.callStackItemType.reset(); } - const actions: IAction[] = []; - const actionsDisposable = createAndFillInContextMenuActions(this.contributedContextMenu, { arg: getContextForContributedActions(element), shouldForwardArgs: true }, actions, this.contextMenuService); + + const primary: IAction[] = []; + const secondary: IAction[] = []; + const result = { primary, secondary }; + const actionsDisposable = createAndFillInContextMenuActions(this.menu, { arg: getContextForContributedActions(element), shouldForwardArgs: true }, result, this.contextMenuService, g => g === 'inline'); this.contextMenuService.showContextMenu({ getAnchor: () => e.anchor, - getActions: () => actions, + getActions: () => result.secondary, getActionsContext: () => getContext(element), onHide: () => dispose(actionsDisposable) }); @@ -406,6 +409,7 @@ interface ISessionTemplateData { stateLabel: HTMLSpanElement; label: HighlightedLabel; actionBar: ActionBar; + elementDisposable?: IDisposable; } interface IErrorTemplateData { @@ -430,6 +434,7 @@ class SessionsRenderer implements ITreeRenderer g === 'inline'); + data.actionBar.push(actions, { icon: true, label: false }); data.stateLabel.hidden = false; @@ -476,6 +487,12 @@ class SessionsRenderer implements ITreeRenderer, _: number, templateData: ISessionTemplateData): void { + if (templateData.elementDisposable) { + templateData.elementDisposable.dispose(); + } + } } class ThreadsRenderer implements ITreeRenderer {