Skip to content

Commit 4869f07

Browse files
authored
Preserve breakpoint ids in workspace state (microsoft#182704)
1 parent 1c8bc27 commit 4869f07

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/vs/workbench/contrib/debug/common/debugModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ export abstract class BaseBreakpoint extends Enablement implements IBaseBreakpoi
852852

853853
toJSON(): any {
854854
const result = Object.create(null);
855+
result.id = this.getId();
855856
result.enabled = this.enabled;
856857
result.condition = this.condition;
857858
result.hitCondition = this.hitCondition;

src/vs/workbench/contrib/debug/common/debugStorage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class DebugStorage {
3939
let result: Breakpoint[] | undefined;
4040
try {
4141
result = JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => {
42-
return new Breakpoint(URI.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData, this.textFileService, this.uriIdentityService, this.logService);
42+
return new Breakpoint(URI.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData, this.textFileService, this.uriIdentityService, this.logService, breakpoint.id);
4343
});
4444
} catch (e) { }
4545

@@ -50,7 +50,7 @@ export class DebugStorage {
5050
let result: FunctionBreakpoint[] | undefined;
5151
try {
5252
result = JSON.parse(this.storageService.get(DEBUG_FUNCTION_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((fb: any) => {
53-
return new FunctionBreakpoint(fb.name, fb.enabled, fb.hitCondition, fb.condition, fb.logMessage);
53+
return new FunctionBreakpoint(fb.name, fb.enabled, fb.hitCondition, fb.condition, fb.logMessage, fb.id);
5454
});
5555
} catch (e) { }
5656

@@ -72,7 +72,7 @@ export class DebugStorage {
7272
let result: DataBreakpoint[] | undefined;
7373
try {
7474
result = JSON.parse(this.storageService.get(DEBUG_DATA_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((dbp: any) => {
75-
return new DataBreakpoint(dbp.description, dbp.dataId, true, dbp.enabled, dbp.hitCondition, dbp.condition, dbp.logMessage, dbp.accessTypes, dbp.accessType);
75+
return new DataBreakpoint(dbp.description, dbp.dataId, true, dbp.enabled, dbp.hitCondition, dbp.condition, dbp.logMessage, dbp.accessTypes, dbp.accessType, dbp.id);
7676
});
7777
} catch (e) { }
7878

src/vs/workbench/contrib/debug/test/common/debugModel.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as assert from 'assert';
7-
import { ExceptionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
7+
import { ExceptionBreakpoint, FunctionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
88

99
suite('DebugModel', () => {
10+
suite('FunctionBreakpoint', () => {
11+
test('Id is saved', () => {
12+
const fbp = new FunctionBreakpoint('function', true, 'hit condition', 'condition', 'log message');
13+
const strigified = JSON.stringify(fbp);
14+
const parsed = JSON.parse(strigified);
15+
assert.equal(parsed.id, fbp.getId());
16+
});
17+
});
1018
suite('ExceptionBreakpoint', () => {
1119
test('Restored matches new', () => {
1220
const ebp = new ExceptionBreakpoint('id', 'label', true, true, 'condition', 'description', 'condition description', false);

0 commit comments

Comments
 (0)