Skip to content

Commit 15e410b

Browse files
committed
Pending breakpoint should be saved across restarts
fixes microsoft#103165
1 parent 95e42d7 commit 15e410b

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/vs/workbench/contrib/debug/browser/debugService.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ export class DebugService implements IDebugService {
817817
async enableOrDisableBreakpoints(enable: boolean, breakpoint?: IEnablement): Promise<void> {
818818
if (breakpoint) {
819819
this.model.setEnablement(breakpoint, enable);
820+
this.debugStorage.storeBreakpoints(this.model);
820821
if (breakpoint instanceof Breakpoint) {
821822
await this.sendBreakpoints(breakpoint.uri);
822823
} else if (breakpoint instanceof FunctionBreakpoint) {
@@ -828,6 +829,7 @@ export class DebugService implements IDebugService {
828829
}
829830
} else {
830831
this.model.enableOrDisableAllBreakpoints(enable);
832+
this.debugStorage.storeBreakpoints(this.model);
831833
await this.sendAllBreakpoints();
832834
}
833835
this.debugStorage.storeBreakpoints(this.model);
@@ -838,19 +840,23 @@ export class DebugService implements IDebugService {
838840
breakpoints.forEach(bp => aria.status(nls.localize('breakpointAdded', "Added breakpoint, line {0}, file {1}", bp.lineNumber, uri.fsPath)));
839841
breakpoints.forEach(bp => this.telemetry.logDebugAddBreakpoint(bp, context));
840842

843+
// In some cases we need to store breakpoints before we send them because sending them can take a long time
844+
// And after sending them because the debug adapter can attach adapter data to a breakpoint
845+
this.debugStorage.storeBreakpoints(this.model);
841846
await this.sendBreakpoints(uri);
842847
this.debugStorage.storeBreakpoints(this.model);
843848
return breakpoints;
844849
}
845850

846851
async updateBreakpoints(uri: uri, data: Map<string, DebugProtocol.Breakpoint>, sendOnResourceSaved: boolean): Promise<void> {
847852
this.model.updateBreakpoints(data);
853+
this.debugStorage.storeBreakpoints(this.model);
848854
if (sendOnResourceSaved) {
849855
this.breakpointsToSendOnResourceSaved.add(uri.toString());
850856
} else {
851857
await this.sendBreakpoints(uri);
858+
this.debugStorage.storeBreakpoints(this.model);
852859
}
853-
this.debugStorage.storeBreakpoints(this.model);
854860
}
855861

856862
async removeBreakpoints(id?: string): Promise<void> {
@@ -860,8 +866,8 @@ export class DebugService implements IDebugService {
860866

861867
this.model.removeBreakpoints(toRemove);
862868

863-
await Promise.all(urisToClear.map(uri => this.sendBreakpoints(uri)));
864869
this.debugStorage.storeBreakpoints(this.model);
870+
await Promise.all(urisToClear.map(uri => this.sendBreakpoints(uri)));
865871
}
866872

867873
setBreakpointsActivated(activated: boolean): Promise<void> {
@@ -876,27 +882,27 @@ export class DebugService implements IDebugService {
876882

877883
async renameFunctionBreakpoint(id: string, newFunctionName: string): Promise<void> {
878884
this.model.renameFunctionBreakpoint(id, newFunctionName);
879-
await this.sendFunctionBreakpoints();
880885
this.debugStorage.storeBreakpoints(this.model);
886+
await this.sendFunctionBreakpoints();
881887
}
882888

883889
async removeFunctionBreakpoints(id?: string): Promise<void> {
884890
this.model.removeFunctionBreakpoints(id);
885-
await this.sendFunctionBreakpoints();
886891
this.debugStorage.storeBreakpoints(this.model);
892+
await this.sendFunctionBreakpoints();
887893
}
888894

889895
async addDataBreakpoint(label: string, dataId: string, canPersist: boolean, accessTypes: DebugProtocol.DataBreakpointAccessType[] | undefined): Promise<void> {
890896
this.model.addDataBreakpoint(label, dataId, canPersist, accessTypes);
897+
this.debugStorage.storeBreakpoints(this.model);
891898
await this.sendDataBreakpoints();
892-
893899
this.debugStorage.storeBreakpoints(this.model);
894900
}
895901

896902
async removeDataBreakpoints(id?: string): Promise<void> {
897903
this.model.removeDataBreakpoints(id);
898-
await this.sendDataBreakpoints();
899904
this.debugStorage.storeBreakpoints(this.model);
905+
await this.sendDataBreakpoints();
900906
}
901907

902908
async sendAllBreakpoints(session?: IDebugSession): Promise<any> {
@@ -909,7 +915,6 @@ export class DebugService implements IDebugService {
909915

910916
private async sendBreakpoints(modelUri: uri, sourceModified = false, session?: IDebugSession): Promise<void> {
911917
const breakpointsToSend = this.model.getBreakpoints({ uri: modelUri, enabledOnly: true });
912-
913918
await sendToOneOrAllSessions(this.model, session, s => s.sendBreakpoints(modelUri, breakpointsToSend, sourceModified));
914919
}
915920

@@ -923,10 +928,10 @@ export class DebugService implements IDebugService {
923928
});
924929
}
925930

926-
private sendDataBreakpoints(session?: IDebugSession): Promise<void> {
931+
private async sendDataBreakpoints(session?: IDebugSession): Promise<void> {
927932
const breakpointsToSend = this.model.getDataBreakpoints().filter(fbp => fbp.enabled && this.model.areBreakpointsActivated());
928933

929-
return sendToOneOrAllSessions(this.model, session, async s => {
934+
await sendToOneOrAllSessions(this.model, session, async s => {
930935
if (s.capabilities.supportsDataBreakpoints) {
931936
await s.sendDataBreakpoints(breakpointsToSend);
932937
}

0 commit comments

Comments
 (0)