From accd8597f09f39e828d2284cbcaf40e4be4e83bb Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 19 Sep 2019 11:14:57 +0200 Subject: [PATCH] debug: dispose context menu actions on hide. Also some breakpoint polish --- .../browser/breakpointEditorContribution.ts | 21 ++++++++++++------- .../contrib/debug/browser/breakpointsView.ts | 3 ++- .../workbench/contrib/debug/browser/repl.ts | 3 ++- .../contrib/debug/browser/variablesView.ts | 4 +++- .../debug/browser/watchExpressionsView.ts | 4 +++- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts index fda9ec6e6ea..ea9cd778675 100644 --- a/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts @@ -166,11 +166,13 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { const anchor = { x: e.event.posx, y: e.event.posy }; const breakpoints = this.debugService.getModel().getBreakpoints({ lineNumber, uri }); + const actions = this.getContextMenuActions(breakpoints, uri, lineNumber); this.contextMenuService.showContextMenu({ getAnchor: () => anchor, - getActions: () => this.getContextMenuActions(breakpoints, uri, lineNumber), - getActionsContext: () => breakpoints.length ? breakpoints[0] : undefined + getActions: () => actions, + getActionsContext: () => breakpoints.length ? breakpoints[0] : undefined, + onHide: () => dispose(actions) }); } else { const breakpoints = this.debugService.getModel().getBreakpoints({ uri, lineNumber }); @@ -371,7 +373,8 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { let inlineWidget: InlineBreakpointWidget | undefined = undefined; const breakpoint = breakpoints[index]; if (breakpoint.column) { - inlineWidget = new InlineBreakpointWidget(activeCodeEditor, decorationId, desiredBreakpointDecorations[index].options.glyphMarginClassName, breakpoint, this.debugService, this.contextMenuService, () => this.getContextMenuActions([breakpoint], activeCodeEditor.getModel().uri, breakpoint.lineNumber, breakpoint.column)); + const contextMenuActions = () => this.getContextMenuActions([breakpoint], activeCodeEditor.getModel().uri, breakpoint.lineNumber, breakpoint.column); + inlineWidget = new InlineBreakpointWidget(activeCodeEditor, decorationId, desiredBreakpointDecorations[index].options.glyphMarginClassName, breakpoint, this.debugService, this.contextMenuService, contextMenuActions); } return { @@ -395,7 +398,8 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { this.candidateDecorations = candidateDecorationIds.map((decorationId, index) => { const candidate = desiredCandidateDecorations[index]; const cssClass = candidate.breakpoint ? undefined : 'debug-breakpoint-disabled'; - const inlineWidget = new InlineBreakpointWidget(activeCodeEditor, decorationId, cssClass, candidate.breakpoint, this.debugService, this.contextMenuService, () => this.getContextMenuActions([], activeCodeEditor.getModel().uri, candidate.range.startLineNumber, candidate.range.startColumn)); + const contextMenuActions = () => this.getContextMenuActions(candidate.breakpoint ? [candidate.breakpoint] : [], activeCodeEditor.getModel().uri, candidate.range.startLineNumber, candidate.range.startColumn); + const inlineWidget = new InlineBreakpointWidget(activeCodeEditor, decorationId, cssClass, candidate.breakpoint, this.debugService, this.contextMenuService, contextMenuActions); return { decorationId, @@ -524,14 +528,15 @@ class InlineBreakpointWidget implements IContentWidget, IDisposable { await this.debugService.addBreakpoints(this.editor.getModel().uri, [{ lineNumber: this.range!.startLineNumber, column: this.range!.startColumn }], 'debugEditorInlineWidget'); } })); - this.toDispose.push(dom.addDisposableListener(this.domNode, dom.EventType.CONTEXT_MENU, async e => { + this.toDispose.push(dom.addDisposableListener(this.domNode, dom.EventType.CONTEXT_MENU, e => { const event = new StandardMouseEvent(e); const anchor = { x: event.posx, y: event.posy }; - + const actions = this.getContextMenuActions(); this.contextMenuService.showContextMenu({ getAnchor: () => anchor, - getActions: () => this.getContextMenuActions(), - getActionsContext: () => this.breakpoint + getActions: () => actions, + getActionsContext: () => this.breakpoint, + onHide: () => dispose(actions) }); })); } diff --git a/src/vs/workbench/contrib/debug/browser/breakpointsView.ts b/src/vs/workbench/contrib/debug/browser/breakpointsView.ts index 1eafaff8e61..fa909505898 100644 --- a/src/vs/workbench/contrib/debug/browser/breakpointsView.ts +++ b/src/vs/workbench/contrib/debug/browser/breakpointsView.ts @@ -196,7 +196,8 @@ export class BreakpointsView extends ViewletPanel { this.contextMenuService.showContextMenu({ getAnchor: () => e.anchor, getActions: () => actions, - getActionsContext: () => element + getActionsContext: () => element, + onHide: () => dispose(actions) }); } diff --git a/src/vs/workbench/contrib/debug/browser/repl.ts b/src/vs/workbench/contrib/debug/browser/repl.ts index ec21ca71f2c..6f243668616 100644 --- a/src/vs/workbench/contrib/debug/browser/repl.ts +++ b/src/vs/workbench/contrib/debug/browser/repl.ts @@ -504,7 +504,8 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati this.contextMenuService.showContextMenu({ getAnchor: () => e.anchor, getActions: () => actions, - getActionsContext: () => e.element + getActionsContext: () => e.element, + onHide: () => dispose(actions) }); } diff --git a/src/vs/workbench/contrib/debug/browser/variablesView.ts b/src/vs/workbench/contrib/debug/browser/variablesView.ts index f2f21e715ed..56483de1cb2 100644 --- a/src/vs/workbench/contrib/debug/browser/variablesView.ts +++ b/src/vs/workbench/contrib/debug/browser/variablesView.ts @@ -30,6 +30,7 @@ import { FuzzyScore, createMatches } from 'vs/base/common/filters'; import { HighlightedLabel, IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { dispose } from 'vs/base/common/lifecycle'; const $ = dom.$; let forgetScopes = true; @@ -188,7 +189,8 @@ export class VariablesView extends ViewletPanel { this.contextMenuService.showContextMenu({ getAnchor: () => e.anchor, getActions: () => actions, - getActionsContext: () => variable + getActionsContext: () => variable, + onHide: () => dispose(actions) }); } } diff --git a/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts b/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts index 291bb7049a1..b48786ed88b 100644 --- a/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts +++ b/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts @@ -30,6 +30,7 @@ import { FuzzyScore } from 'vs/base/common/filters'; import { IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel'; import { variableSetEmitter, VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { dispose } from 'vs/base/common/lifecycle'; const MAX_VALUE_RENDER_LENGTH_IN_VIEWLET = 1024; @@ -175,7 +176,8 @@ export class WatchExpressionsView extends ViewletPanel { this.contextMenuService.showContextMenu({ getAnchor: () => anchor, getActions: () => actions, - getActionsContext: () => element + getActionsContext: () => element, + onHide: () => dispose(actions) }); } }