Skip to content

Commit 9ba6d40

Browse files
committed
function breakpoint
fixes microsoft#44556
1 parent 0179894 commit 9ba6d40

4 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/vs/workbench/parts/debug/browser/breakpointsView.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,20 @@ export class BreakpointsView extends ViewsViewletPanel {
117117
const actions: IAction[] = [];
118118
const element = e.element;
119119

120-
if (element instanceof Breakpoint) {
120+
if (element instanceof Breakpoint || element instanceof FunctionBreakpoint) {
121121
actions.push(new Action('workbench.action.debug.openEditorAndEditBreakpoint', nls.localize('editConditionalBreakpoint', "Edit Breakpoint..."), undefined, true, () => {
122-
return openBreakpointSource(element, false, false, this.debugService, this.editorService).then(editor => {
123-
const codeEditor = editor.getControl();
124-
if (isCodeEditor(codeEditor)) {
125-
codeEditor.getContribution<IDebugEditorContribution>(EDITOR_CONTRIBUTION_ID).showBreakpointWidget(element.lineNumber, element.column);
126-
}
127-
});
122+
if (element instanceof Breakpoint) {
123+
return openBreakpointSource(element, false, false, this.debugService, this.editorService).then(editor => {
124+
const codeEditor = editor.getControl();
125+
if (isCodeEditor(codeEditor)) {
126+
codeEditor.getContribution<IDebugEditorContribution>(EDITOR_CONTRIBUTION_ID).showBreakpointWidget(element.lineNumber, element.column);
127+
}
128+
});
129+
}
130+
131+
this.debugService.getViewModel().setSelectedFunctionBreakpoint(element);
132+
this.onBreakpointsChange();
133+
return undefined;
128134
}));
129135
actions.push(new Separator());
130136
}
@@ -483,7 +489,9 @@ class FunctionBreakpointInputRenderer implements IRenderer<IFunctionBreakpoint,
483489
}
484490
}));
485491
toDispose.push(dom.addDisposableListener(inputBox.inputElement, 'blur', () => {
486-
wrapUp(true);
492+
if (!template.breakpoint.name) {
493+
wrapUp(true);
494+
}
487495
}));
488496

489497
template.inputBox = inputBox;

src/vs/workbench/parts/debug/browser/debugCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as errors from 'vs/base/common/errors';
1111
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
1212
import { IListService } from 'vs/platform/list/browser/listService';
1313
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
14-
import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_NOT_IN_DEBUG_REPL, CONTEXT_EXPRESSION_SELECTED } from 'vs/workbench/parts/debug/common/debug';
14+
import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_NOT_IN_DEBUG_REPL, CONTEXT_EXPRESSION_SELECTED, CONTEXT_BREAKPOINT_SELECTED } from 'vs/workbench/parts/debug/common/debug';
1515
import { Expression, Variable, Breakpoint, FunctionBreakpoint } from 'vs/workbench/parts/debug/common/debugModel';
1616
import { IExtensionsViewlet, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/parts/extensions/common/extensions';
1717
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
@@ -111,7 +111,7 @@ export function registerCommands(): void {
111111
KeybindingsRegistry.registerCommandAndKeybindingRule({
112112
id: 'debug.removeBreakpoint',
113113
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
114-
when: CONTEXT_BREAKPOINTS_FOCUSED,
114+
when: ContextKeyExpr.and(CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_BREAKPOINT_SELECTED.toNegated()),
115115
primary: KeyCode.Delete,
116116
mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace },
117117
handler: (accessor) => {

src/vs/workbench/parts/debug/common/debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const CONTEXT_BREAKPOINTS_FOCUSED = new RawContextKey<boolean>('breakpoin
4141
export const CONTEXT_WATCH_EXPRESSIONS_FOCUSED = new RawContextKey<boolean>('watchExpressionsFocused', true);
4242
export const CONTEXT_VARIABLES_FOCUSED = new RawContextKey<boolean>('variablesFocused', true);
4343
export const CONTEXT_EXPRESSION_SELECTED = new RawContextKey<boolean>('expressionSelected', false);
44+
export const CONTEXT_BREAKPOINT_SELECTED = new RawContextKey<boolean>('breakpointSelected', false);
4445

4546
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
4647
export const DEBUG_SCHEME = 'debug';

src/vs/workbench/parts/debug/common/debugViewModel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import Event, { Emitter } from 'vs/base/common/event';
7-
import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, IProcess, IThread, IExpression, IFunctionBreakpoint } from 'vs/workbench/parts/debug/common/debug';
7+
import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, IProcess, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED } from 'vs/workbench/parts/debug/common/debug';
88
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
99

1010
export class ViewModel implements IViewModel {
@@ -19,13 +19,15 @@ export class ViewModel implements IViewModel {
1919
private _onDidSelectExpression: Emitter<IExpression>;
2020
private multiProcessView: boolean;
2121
private expressionSelectedContextKey: IContextKey<boolean>;
22+
private breakpointSelectedContextKey: IContextKey<boolean>;
2223

2324
constructor(contextKeyService: IContextKeyService) {
2425
this._onDidFocusProcess = new Emitter<IProcess | undefined>();
2526
this._onDidFocusStackFrame = new Emitter<{ stackFrame: IStackFrame, explicit: boolean }>();
2627
this._onDidSelectExpression = new Emitter<IExpression>();
2728
this.multiProcessView = false;
2829
this.expressionSelectedContextKey = CONTEXT_EXPRESSION_SELECTED.bindTo(contextKeyService);
30+
this.breakpointSelectedContextKey = CONTEXT_BREAKPOINT_SELECTED.bindTo(contextKeyService);
2931
}
3032

3133
public getId(): string {
@@ -87,6 +89,7 @@ export class ViewModel implements IViewModel {
8789

8890
public setSelectedFunctionBreakpoint(functionBreakpoint: IFunctionBreakpoint): void {
8991
this.selectedFunctionBreakpoint = functionBreakpoint;
92+
this.breakpointSelectedContextKey.set(!!functionBreakpoint);
9093
}
9194

9295
public isMultiProcessView(): boolean {

0 commit comments

Comments
 (0)