debug: dispose context menu actions on hide. Also some breakpoint polish

This commit is contained in:
isidor
2019-09-19 11:14:57 +02:00
parent c2dcd0ba67
commit accd8597f0
5 changed files with 23 additions and 12 deletions
@@ -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)
});
}));
}
@@ -196,7 +196,8 @@ export class BreakpointsView extends ViewletPanel {
this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor,
getActions: () => actions,
getActionsContext: () => element
getActionsContext: () => element,
onHide: () => dispose(actions)
});
}
@@ -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)
});
}
@@ -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)
});
}
}
@@ -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)
});
}
}