Skip to content

Commit

Permalink
breakpoints column in the model
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Dec 27, 2016
1 parent 6750efe commit 604e21b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/vs/workbench/parts/debug/browser/debugEditorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ class ToggleBreakpointAction extends EditorAction {
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): TPromise<void> {
const debugService = accessor.get(IDebugService);

const lineNumber = editor.getPosition().lineNumber;
const position = editor.getPosition();
const modelUri = editor.getModel().uri;
const bp = debugService.getModel().getBreakpoints()
.filter(bp => bp.lineNumber === lineNumber && bp.uri.toString() === modelUri.toString()).pop();
.filter(bp => bp.lineNumber === position.lineNumber && bp.uri.toString() === modelUri.toString()).pop();

if (bp) {
return debugService.removeBreakpoints(bp.getId());
}
if (debugService.getConfigurationManager().canSetBreakpointsIn(editor.getModel())) {
return debugService.addBreakpoints(modelUri, [{ lineNumber }]);
return debugService.addBreakpoints(modelUri, [{ lineNumber: position.lineNumber, column: position.column }]);
}
}
}
Expand Down Expand Up @@ -91,22 +91,22 @@ class RunToCursorAction extends EditorAction {
if (debugService.state !== State.Stopped) {
return TPromise.as(null);
}
const lineNumber = editor.getPosition().lineNumber;
const position = editor.getPosition();
const uri = editor.getModel().uri;

const oneTimeListener = debugService.getViewModel().focusedProcess.session.onDidEvent(event => {
if (event.event === 'stopped' || event.event === 'exit') {
const toRemove = debugService.getModel().getBreakpoints()
.filter(bp => bp.lineNumber === lineNumber && bp.uri.toString() === uri.toString()).pop();
.filter(bp => bp.lineNumber === position.lineNumber && bp.uri.toString() === uri.toString()).pop();
if (toRemove) {
debugService.removeBreakpoints(toRemove.getId());
}
oneTimeListener.dispose();
}
});

const bpExists = !!(debugService.getModel().getBreakpoints().filter(bp => bp.lineNumber === lineNumber && bp.uri.toString() === uri.toString()).pop());
return (bpExists ? TPromise.as(null) : debugService.addBreakpoints(uri, [{ lineNumber }])).then(() => {
const bpExists = !!(debugService.getModel().getBreakpoints().filter(bp => bp.column === position.column && bp.lineNumber === position.lineNumber && bp.uri.toString() === uri.toString()).pop());
return (bpExists ? TPromise.as(null) : debugService.addBreakpoints(uri, [{ lineNumber: position.lineNumber, column: position.column }])).then(() => {
debugService.getViewModel().focusedThread.continue();
});
}
Expand Down
16 changes: 7 additions & 9 deletions src/vs/workbench/parts/debug/browser/debugEditorModelManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,26 +181,24 @@ export class DebugEditorModelManager implements IWorkbenchContribution {

const data: IRawBreakpoint[] = [];

const lineToBreakpointDataMap: { [key: number]: { enabled: boolean, condition: string, hitCondition: string } } = {};
const lineToBreakpointDataMap: { [key: number]: IBreakpoint } = {};
this.debugService.getModel().getBreakpoints().filter(bp => bp.uri.toString() === modelUrlStr).forEach(bp => {
lineToBreakpointDataMap[bp.lineNumber] = {
enabled: bp.enabled,
condition: bp.condition,
hitCondition: bp.hitCondition
};
lineToBreakpointDataMap[bp.lineNumber] = bp;
});

const modelUri = modelData.model.uri;
for (let i = 0, len = modelData.breakpointDecorationIds.length; i < len; i++) {
const decorationRange = modelData.model.getDecorationRange(modelData.breakpointDecorationIds[i]);
const lineNumber = modelData.breakpointLines[i];
// check if the line got deleted.
if (decorationRange.endColumn - decorationRange.startColumn > 0) {
// since we know it is collapsed, it cannot grow to multiple lines
data.push({
lineNumber: decorationRange.startLineNumber,
enabled: lineToBreakpointDataMap[modelData.breakpointLines[i]].enabled,
condition: lineToBreakpointDataMap[modelData.breakpointLines[i]].condition,
hitCondition: lineToBreakpointDataMap[modelData.breakpointLines[i]].hitCondition
enabled: lineToBreakpointDataMap[lineNumber].enabled,
condition: lineToBreakpointDataMap[lineNumber].condition,
hitCondition: lineToBreakpointDataMap[lineNumber].hitCondition,
column: lineToBreakpointDataMap[lineNumber].column
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export interface IEnablement extends ITreeElement {

export interface IRawBreakpoint {
lineNumber: number;
column?: number;
enabled?: boolean;
condition?: string;
hitCondition?: string;
Expand All @@ -188,6 +189,7 @@ export interface IRawBreakpoint {
export interface IBreakpoint extends IEnablement {
uri: uri;
lineNumber: number;
column: number;
condition: string;
hitCondition: string;
verified: boolean;
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/parts/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ export class Breakpoint implements debug.IBreakpoint {
constructor(
public uri: uri,
public lineNumber: number,
public column: number,
public enabled: boolean,
public condition: string,
public hitCondition: string
Expand Down Expand Up @@ -736,7 +737,7 @@ export class Model implements debug.IModel {

public addBreakpoints(uri: uri, rawData: debug.IRawBreakpoint[]): void {
this.breakpoints = this.breakpoints.concat(rawData.map(rawBp =>
new Breakpoint(uri, rawBp.lineNumber, rawBp.enabled, rawBp.condition, rawBp.hitCondition)));
new Breakpoint(uri, rawBp.lineNumber, rawBp.column, rawBp.enabled, rawBp.condition, rawBp.hitCondition)));
this.breakpointsActivated = true;
this._onDidChangeBreakpoints.fire();
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/debug/electron-browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export class DebugService implements debug.IDebugService {
let result: Breakpoint[];
try {
result = JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => {
return new Breakpoint(uri.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition);
return new Breakpoint(uri.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition);
});
} catch (e) { }

Expand Down Expand Up @@ -926,7 +926,7 @@ export class DebugService implements debug.IDebugService {
return session.setBreakpoints({
source: rawSource,
lines: breakpointsToSend.map(bp => bp.lineNumber),
breakpoints: breakpointsToSend.map(bp => ({ line: bp.lineNumber, condition: bp.condition, hitCondition: bp.hitCondition })),
breakpoints: breakpointsToSend.map(bp => ({ line: bp.lineNumber, condition: bp.condition, hitCondition: bp.hitCondition, column: bp.column })),
sourceModified
}).then(response => {
if (!response || !response.body) {
Expand Down

0 comments on commit 604e21b

Please sign in to comment.