diff --git a/src/vs/workbench/parts/debug/common/debugSource.ts b/src/vs/workbench/parts/debug/common/debugSource.ts index c213d2d601948bbe1eae03ababd6c00fada6c001..f948d90b1f1a9bd94270e9ea47140c6151109439 100644 --- a/src/vs/workbench/parts/debug/common/debugSource.ts +++ b/src/vs/workbench/parts/debug/common/debugSource.ts @@ -36,13 +36,15 @@ export class Source { } public static toRawSource(uri: uri, model: IModel): DebugProtocol.Source { - // first try to find the raw source amongst the stack frames - since that represenation has more data (source reference), - const threads = model.getThreads(); - for (let threadId in threads) { - if (threads.hasOwnProperty(threadId) && threads[threadId].callStack) { - const found = threads[threadId].callStack.filter(sf => sf.source.uri.toString() === uri.toString()).pop(); - if (found) { - return found.source.raw; + if (model) { + // first try to find the raw source amongst the stack frames - since that represenation has more data (source reference), + const threads = model.getThreads(); + for (let threadId in threads) { + if (threads.hasOwnProperty(threadId) && threads[threadId].callStack) { + const found = threads[threadId].callStack.filter(sf => sf.source.uri.toString() === uri.toString()).pop(); + if (found) { + return found.source.raw; + } } } } diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index e4068c8160ccbb0a2e8759547cc540482a0afa34..1cd6e52c20146eea8660ef7ad1eed52e818d9a46 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -782,15 +782,17 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService } private sendBreakpoints(modelUri: uri): Promise { + if (!this.session || !this.session.readyForBreakpoints) { + return Promise.as(null); + } + const breakpointsToSend = arrays.distinct( this.model.getBreakpoints().filter(bp => this.model.areBreakpointsActivated() && bp.enabled && bp.source.uri.toString() === modelUri.toString()), bp => `${ bp.desiredLineNumber }` ); - if (!this.session || !this.session.readyForBreakpoints || breakpointsToSend.length === 0) { - return Promise.as(null); - } + const rawSource = breakpointsToSend.length > 0 ? breakpointsToSend[0].source.raw : Source.toRawSource(modelUri, null); - return this.session.setBreakpoints({ source: breakpointsToSend[0].source.raw, lines: breakpointsToSend.map(bp => bp.desiredLineNumber), + return this.session.setBreakpoints({ source: rawSource, lines: breakpointsToSend.map(bp => bp.desiredLineNumber), breakpoints: breakpointsToSend.map(bp => ({ line: bp.desiredLineNumber, condition: bp.condition })) }).then(response => { const data: {[id: string]: { line: number, verified: boolean } } = { };