Skip to content

Commit

Permalink
debug: improve breakpoint handling
Browse files Browse the repository at this point in the history
fixes #8642
  • Loading branch information
isidorn committed Sep 27, 2017
1 parent 904aeee commit 310980c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/vs/workbench/parts/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions src/vs/workbench/parts/debug/electron-browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 310980c

Please sign in to comment.