提交 cdced4d7 编写于 作者: I isidor

debug: simplify breakopint line number - no longer show how the line number jumped

上级 e3020d00
...@@ -101,7 +101,7 @@ class RunToCursorAction extends EditorAction { ...@@ -101,7 +101,7 @@ class RunToCursorAction extends EditorAction {
const oneTimeListener = debugService.getViewModel().focusedProcess.session.onDidEvent(event => { const oneTimeListener = debugService.getViewModel().focusedProcess.session.onDidEvent(event => {
if (event.event === 'stopped' || event.event === 'exit') { if (event.event === 'stopped' || event.event === 'exit') {
const toRemove = debugService.getModel().getBreakpoints() const toRemove = debugService.getModel().getBreakpoints()
.filter(bp => bp.desiredLineNumber === lineNumber && bp.uri.toString() === uri.toString()).pop(); .filter(bp => bp.lineNumber === lineNumber && bp.uri.toString() === uri.toString()).pop();
if (toRemove) { if (toRemove) {
debugService.removeBreakpoints(toRemove.getId()); debugService.removeBreakpoints(toRemove.getId());
} }
......
...@@ -186,7 +186,6 @@ export interface IRawBreakpoint { ...@@ -186,7 +186,6 @@ export interface IRawBreakpoint {
export interface IBreakpoint extends IEnablement { export interface IBreakpoint extends IEnablement {
uri: uri; uri: uri;
lineNumber: number; lineNumber: number;
desiredLineNumber: number;
condition: string; condition: string;
hitCondition: string; hitCondition: string;
verified: boolean; verified: boolean;
......
...@@ -570,7 +570,6 @@ export class Process implements debug.IProcess { ...@@ -570,7 +570,6 @@ export class Process implements debug.IProcess {
export class Breakpoint implements debug.IBreakpoint { export class Breakpoint implements debug.IBreakpoint {
public lineNumber: number;
public verified: boolean; public verified: boolean;
public idFromAdapter: number; public idFromAdapter: number;
public message: string; public message: string;
...@@ -578,7 +577,7 @@ export class Breakpoint implements debug.IBreakpoint { ...@@ -578,7 +577,7 @@ export class Breakpoint implements debug.IBreakpoint {
constructor( constructor(
public uri: uri, public uri: uri,
public desiredLineNumber: number, public lineNumber: number,
public enabled: boolean, public enabled: boolean,
public condition: string, public condition: string,
public hitCondition: string public hitCondition: string
...@@ -586,7 +585,6 @@ export class Breakpoint implements debug.IBreakpoint { ...@@ -586,7 +585,6 @@ export class Breakpoint implements debug.IBreakpoint {
if (enabled === undefined) { if (enabled === undefined) {
this.enabled = true; this.enabled = true;
} }
this.lineNumber = this.desiredLineNumber;
this.verified = false; this.verified = false;
this.id = generateUuid(); this.id = generateUuid();
} }
...@@ -755,6 +753,9 @@ export class Model implements debug.IModel { ...@@ -755,6 +753,9 @@ export class Model implements debug.IModel {
bp.message = bpData.message; bp.message = bpData.message;
} }
}); });
// Remove duplicate breakpoints. This can happen when an adapter updates a line number of a breakpoint
this.breakpoints = distinct(this.breakpoints, bp => bp.uri.toString() + bp.lineNumber);
this._onDidChangeBreakpoints.fire(); this._onDidChangeBreakpoints.fire();
} }
...@@ -762,7 +763,6 @@ export class Model implements debug.IModel { ...@@ -762,7 +763,6 @@ export class Model implements debug.IModel {
element.enabled = enable; element.enabled = enable;
if (element instanceof Breakpoint && !element.enabled) { if (element instanceof Breakpoint && !element.enabled) {
var breakpoint = <Breakpoint>element; var breakpoint = <Breakpoint>element;
breakpoint.lineNumber = breakpoint.desiredLineNumber;
breakpoint.verified = false; breakpoint.verified = false;
} }
...@@ -773,7 +773,6 @@ export class Model implements debug.IModel { ...@@ -773,7 +773,6 @@ export class Model implements debug.IModel {
this.breakpoints.forEach(bp => { this.breakpoints.forEach(bp => {
bp.enabled = enable; bp.enabled = enable;
if (!enable) { if (!enable) {
bp.lineNumber = bp.desiredLineNumber;
bp.verified = false; bp.verified = false;
} }
}); });
......
...@@ -375,7 +375,7 @@ export class DebugService implements debug.IDebugService { ...@@ -375,7 +375,7 @@ export class DebugService implements debug.IDebugService {
let result: Breakpoint[]; let result: Breakpoint[];
try { try {
result = JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => { 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.desiredLineNumber || breakpoint.lineNumber, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition); return new Breakpoint(uri.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition);
}); });
} catch (e) { } } catch (e) { }
...@@ -943,10 +943,8 @@ export class DebugService implements debug.IDebugService { ...@@ -943,10 +943,8 @@ export class DebugService implements debug.IDebugService {
return TPromise.as(null); return TPromise.as(null);
} }
const breakpointsToSend = distinct( const breakpointsToSend = distinct(this.model.getBreakpoints().filter(bp => this.model.areBreakpointsActivated() && bp.enabled && bp.uri.toString() === modelUri.toString()),
this.model.getBreakpoints().filter(bp => this.model.areBreakpointsActivated() && bp.enabled && bp.uri.toString() === modelUri.toString()), bp => bp.lineNumber.toString());
bp => `${bp.desiredLineNumber}`
);
let rawSource: DebugProtocol.Source; let rawSource: DebugProtocol.Source;
for (let t of process.getAllThreads()) { for (let t of process.getAllThreads()) {
...@@ -964,8 +962,8 @@ export class DebugService implements debug.IDebugService { ...@@ -964,8 +962,8 @@ export class DebugService implements debug.IDebugService {
return session.setBreakpoints({ return session.setBreakpoints({
source: rawSource, source: rawSource,
lines: breakpointsToSend.map(bp => bp.desiredLineNumber), lines: breakpointsToSend.map(bp => bp.lineNumber),
breakpoints: breakpointsToSend.map(bp => ({ line: bp.desiredLineNumber, condition: bp.condition, hitCondition: bp.hitCondition })), breakpoints: breakpointsToSend.map(bp => ({ line: bp.lineNumber, condition: bp.condition, hitCondition: bp.hitCondition })),
sourceModified sourceModified
}).then(response => { }).then(response => {
if (!response || !response.body) { if (!response || !response.body) {
......
...@@ -1257,7 +1257,7 @@ export class BreakpointsRenderer implements IRenderer { ...@@ -1257,7 +1257,7 @@ export class BreakpointsRenderer implements IRenderer {
this.debugService.getModel().areBreakpointsActivated() ? tree.removeTraits('disabled', [breakpoint]) : tree.addTraits('disabled', [breakpoint]); this.debugService.getModel().areBreakpointsActivated() ? tree.removeTraits('disabled', [breakpoint]) : tree.addTraits('disabled', [breakpoint]);
data.name.textContent = getPathLabel(paths.basename(breakpoint.uri.fsPath), this.contextService); data.name.textContent = getPathLabel(paths.basename(breakpoint.uri.fsPath), this.contextService);
data.lineNumber.textContent = breakpoint.desiredLineNumber !== breakpoint.lineNumber ? breakpoint.desiredLineNumber + ' \u2192 ' + breakpoint.lineNumber : '' + breakpoint.lineNumber; data.lineNumber.textContent = breakpoint.lineNumber.toString();
data.filePath.textContent = getPathLabel(paths.dirname(breakpoint.uri.fsPath), this.contextService); data.filePath.textContent = getPathLabel(paths.dirname(breakpoint.uri.fsPath), this.contextService);
data.checkbox.checked = breakpoint.enabled; data.checkbox.checked = breakpoint.enabled;
data.actionBar.context = breakpoint; data.actionBar.context = breakpoint;
......
...@@ -382,7 +382,7 @@ export class BreakpointsView extends AdaptiveCollapsibleViewletView { ...@@ -382,7 +382,7 @@ export class BreakpointsView extends AdaptiveCollapsibleViewletView {
return paths.basename(first.uri.fsPath).localeCompare(paths.basename(second.uri.fsPath)); return paths.basename(first.uri.fsPath).localeCompare(paths.basename(second.uri.fsPath));
} }
return first.desiredLineNumber - second.desiredLineNumber; return first.lineNumber - second.lineNumber;
} }
} }
}, debugTreeOptions(nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'breakpointsAriaTreeLabel' }, "Debug Breakpoints"))); }, debugTreeOptions(nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'breakpointsAriaTreeLabel' }, "Debug Breakpoints")));
......
...@@ -57,12 +57,10 @@ suite('Debug - Model', () => { ...@@ -57,12 +57,10 @@ suite('Debug - Model', () => {
assert.equal(model.getBreakpoints().length, 5); assert.equal(model.getBreakpoints().length, 5);
var bp = model.getBreakpoints()[0]; var bp = model.getBreakpoints()[0];
var originalLineLumber = bp.lineNumber;
const update: any = {}; const update: any = {};
update[bp.getId()] = { line: 100, verified: false }; update[bp.getId()] = { line: 100, verified: false };
model.updateBreakpoints(update); model.updateBreakpoints(update);
assert.equal(bp.lineNumber, 100); assert.equal(bp.lineNumber, 100);
assert.equal(bp.desiredLineNumber, originalLineLumber);
model.enableOrDisableAllBreakpoints(false); model.enableOrDisableAllBreakpoints(false);
model.getBreakpoints().forEach(bp => { model.getBreakpoints().forEach(bp => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册