From 310980c332970577f21e6ee83c088c101c9898e6 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 27 Sep 2017 15:33:00 +0200 Subject: [PATCH] debug: improve breakpoint handling fixes #8642 --- src/vs/workbench/parts/debug/common/debugModel.ts | 12 ++++++++---- .../parts/debug/electron-browser/debugService.ts | 11 ++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/parts/debug/common/debugModel.ts b/src/vs/workbench/parts/debug/common/debugModel.ts index aaa64b02a3da2..3fcc0b3682719 100644 --- a/src/vs/workbench/parts/debug/common/debugModel.ts +++ b/src/vs/workbench/parts/debug/common/debugModel.ts @@ -864,12 +864,16 @@ export class Model implements IModel { this._onDidChangeBreakpoints.fire(); } - public addBreakpoints(uri: uri, rawData: IRawBreakpoint[], adapterData: any = undefined): void { - this.breakpoints = this.breakpoints.concat(rawData.map(rawBp => - new Breakpoint(uri, rawBp.lineNumber, rawBp.column, rawBp.enabled, rawBp.condition, rawBp.hitCondition, adapterData))); + public addBreakpoints(uri: uri, rawData: IRawBreakpoint[], fireEvent = true): Breakpoint[] { + const newBreakpoints = rawData.map(rawBp => new Breakpoint(uri, rawBp.lineNumber, rawBp.column, rawBp.enabled, rawBp.condition, rawBp.hitCondition, undefined)); + this.breakpoints = this.breakpoints.concat(newBreakpoints); this.breakpointsActivated = true; this.breakpoints = distinct(this.breakpoints, bp => `${bp.uri.toString()}:${bp.lineNumber}:${bp.column}`); - this._onDidChangeBreakpoints.fire(); + if (fireEvent) { + this._onDidChangeBreakpoints.fire(); + } + + return newBreakpoints; } public removeBreakpoints(toRemove: IBreakpoint[]): void { diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 3564fd84e2eb3..3f1e43de48347 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -373,13 +373,14 @@ export class DebugService implements debug.IDebugService { if (event.body.reason === 'new' && event.body.breakpoint.source) { const source = process.getSource(event.body.breakpoint.source); - this.model.addBreakpoints(source.uri, [{ + const bps = this.model.addBreakpoints(source.uri, [{ column: event.body.breakpoint.column, enabled: true, - lineNumber: event.body.breakpoint.line - }], source.raw.adapterData); - const newBreakpoint = this.model.getBreakpoints().filter(bp => bp.idFromAdapter === event.body.breakpoint.id).pop(); - this.model.updateBreakpoints({ [newBreakpoint.getId()]: event.body.breakpoint }); + lineNumber: event.body.breakpoint.line, + }], false); + if (bps.length === 1) { + this.model.updateBreakpoints({ [bps[0].getId()]: event.body.breakpoint }); + } } if (event.body.reason === 'removed') {