diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index 55abf0ca1cdfd73e06909f8af27a36fd4341446b..348da3e40cb99fe3832412b12ef151ec01f579e8 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -817,6 +817,7 @@ export class DebugService implements IDebugService { async enableOrDisableBreakpoints(enable: boolean, breakpoint?: IEnablement): Promise { if (breakpoint) { this.model.setEnablement(breakpoint, enable); + this.debugStorage.storeBreakpoints(this.model); if (breakpoint instanceof Breakpoint) { await this.sendBreakpoints(breakpoint.uri); } else if (breakpoint instanceof FunctionBreakpoint) { @@ -828,6 +829,7 @@ export class DebugService implements IDebugService { } } else { this.model.enableOrDisableAllBreakpoints(enable); + this.debugStorage.storeBreakpoints(this.model); await this.sendAllBreakpoints(); } this.debugStorage.storeBreakpoints(this.model); @@ -838,6 +840,9 @@ export class DebugService implements IDebugService { breakpoints.forEach(bp => aria.status(nls.localize('breakpointAdded', "Added breakpoint, line {0}, file {1}", bp.lineNumber, uri.fsPath))); breakpoints.forEach(bp => this.telemetry.logDebugAddBreakpoint(bp, context)); + // In some cases we need to store breakpoints before we send them because sending them can take a long time + // And after sending them because the debug adapter can attach adapter data to a breakpoint + this.debugStorage.storeBreakpoints(this.model); await this.sendBreakpoints(uri); this.debugStorage.storeBreakpoints(this.model); return breakpoints; @@ -845,12 +850,13 @@ export class DebugService implements IDebugService { async updateBreakpoints(uri: uri, data: Map, sendOnResourceSaved: boolean): Promise { this.model.updateBreakpoints(data); + this.debugStorage.storeBreakpoints(this.model); if (sendOnResourceSaved) { this.breakpointsToSendOnResourceSaved.add(uri.toString()); } else { await this.sendBreakpoints(uri); + this.debugStorage.storeBreakpoints(this.model); } - this.debugStorage.storeBreakpoints(this.model); } async removeBreakpoints(id?: string): Promise { @@ -860,8 +866,8 @@ export class DebugService implements IDebugService { this.model.removeBreakpoints(toRemove); - await Promise.all(urisToClear.map(uri => this.sendBreakpoints(uri))); this.debugStorage.storeBreakpoints(this.model); + await Promise.all(urisToClear.map(uri => this.sendBreakpoints(uri))); } setBreakpointsActivated(activated: boolean): Promise { @@ -876,27 +882,27 @@ export class DebugService implements IDebugService { async renameFunctionBreakpoint(id: string, newFunctionName: string): Promise { this.model.renameFunctionBreakpoint(id, newFunctionName); - await this.sendFunctionBreakpoints(); this.debugStorage.storeBreakpoints(this.model); + await this.sendFunctionBreakpoints(); } async removeFunctionBreakpoints(id?: string): Promise { this.model.removeFunctionBreakpoints(id); - await this.sendFunctionBreakpoints(); this.debugStorage.storeBreakpoints(this.model); + await this.sendFunctionBreakpoints(); } async addDataBreakpoint(label: string, dataId: string, canPersist: boolean, accessTypes: DebugProtocol.DataBreakpointAccessType[] | undefined): Promise { this.model.addDataBreakpoint(label, dataId, canPersist, accessTypes); + this.debugStorage.storeBreakpoints(this.model); await this.sendDataBreakpoints(); - this.debugStorage.storeBreakpoints(this.model); } async removeDataBreakpoints(id?: string): Promise { this.model.removeDataBreakpoints(id); - await this.sendDataBreakpoints(); this.debugStorage.storeBreakpoints(this.model); + await this.sendDataBreakpoints(); } async sendAllBreakpoints(session?: IDebugSession): Promise { @@ -909,7 +915,6 @@ export class DebugService implements IDebugService { private async sendBreakpoints(modelUri: uri, sourceModified = false, session?: IDebugSession): Promise { const breakpointsToSend = this.model.getBreakpoints({ uri: modelUri, enabledOnly: true }); - await sendToOneOrAllSessions(this.model, session, s => s.sendBreakpoints(modelUri, breakpointsToSend, sourceModified)); } @@ -923,10 +928,10 @@ export class DebugService implements IDebugService { }); } - private sendDataBreakpoints(session?: IDebugSession): Promise { + private async sendDataBreakpoints(session?: IDebugSession): Promise { const breakpointsToSend = this.model.getDataBreakpoints().filter(fbp => fbp.enabled && this.model.areBreakpointsActivated()); - return sendToOneOrAllSessions(this.model, session, async s => { + await sendToOneOrAllSessions(this.model, session, async s => { if (s.capabilities.supportsDataBreakpoints) { await s.sendDataBreakpoints(breakpointsToSend); }