Skip to content

Commit

Permalink
Fix breakpoint context menu behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: thegecko <[email protected]>
  • Loading branch information
thegecko committed Nov 5, 2019
1 parent 05f2e07 commit 61f2e70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ElectronContextMenuRenderer implements ContextMenuRenderer {
// native context menu stops the event loop, so there is no keyboard events
this.context.resetAltPressed();
if (onHide) {
onHide();
menu.once('menu-will-close', () => onHide());
}
}

Expand Down
21 changes: 13 additions & 8 deletions packages/debug/src/browser/editor/debug-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,20 @@ export class DebugEditorModel implements Disposable {
get position(): monaco.Position {
return this._position || this.editor.getControl().getPosition()!;
}

get breakpoint(): DebugBreakpoint | undefined {
return this.getBreakpoint();
// Use stored position or control position
return this.getBreakpoint(this.position);
}
protected getBreakpoint(position: monaco.Position = this.position): DebugBreakpoint | undefined {
protected getBreakpoint(position: monaco.Position): DebugBreakpoint | undefined {
return this.sessions.getBreakpoint(this.uri, position.lineNumber);
}

toggleBreakpoint(): void {
this.doToggleBreakpoint();
// Use stored position or control position
this.doToggleBreakpoint(this.position);
}
protected doToggleBreakpoint(position: monaco.Position = this.position): void {
protected doToggleBreakpoint(position: monaco.Position): void {
const breakpoint = this.getBreakpoint(position);
if (breakpoint) {
breakpoint.remove();
Expand Down Expand Up @@ -285,10 +289,11 @@ export class DebugEditorModel implements Disposable {
protected handleMouseDown(event: monaco.editor.IEditorMouseEvent): void {
if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
if (event.event.rightButton) {
this._position = event.target.position!;
this.contextMenu.render(DebugEditorModel.CONTEXT_MENU, event.event.browserEvent, () =>
setTimeout(() => this._position = undefined)
);
this.editor.focus();
setTimeout(() => {
this._position = event.target.position!;
this.contextMenu.render(DebugEditorModel.CONTEXT_MENU, event.event.browserEvent);
});
} else {
this.doToggleBreakpoint(event.target.position!);
}
Expand Down
1 change: 1 addition & 0 deletions packages/debug/src/browser/editor/debug-editor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class DebugEditorService {
model.breakpointWidget.show({ breakpoint, context });
} else {
model.breakpointWidget.show({
// Use position stored by context menu or current editor position
position: model.position,
context
});
Expand Down

0 comments on commit 61f2e70

Please sign in to comment.