diff --git a/src/chrome/chromeDebugAdapter.ts b/src/chrome/chromeDebugAdapter.ts index e782f3ef2..f9a5e80ef 100644 --- a/src/chrome/chromeDebugAdapter.ts +++ b/src/chrome/chromeDebugAdapter.ts @@ -1423,6 +1423,10 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { // If the frame doesn't have a function name, it's either an anonymous function // or eval script. If its source has a name, it's probably an anonymous function. const frameName = functionName || (script.url ? '(anonymous function)' : '(eval code)'); + if (script.hasSourceURL) { + if (!global["evalSources"]) global["evalSources"] = []; + global["evalSources"].push(script.url); + } return { id: this._frameHandles.create(frame), name: frameName, diff --git a/src/sourceMaps/sourceMap.ts b/src/sourceMaps/sourceMap.ts index c357d64a3..456625f75 100644 --- a/src/sourceMaps/sourceMap.ts +++ b/src/sourceMaps/sourceMap.ts @@ -161,6 +161,7 @@ export class SourceMap { * Will return null instead of a mapping on the next line (different from generatedPositionFor). */ public authoredPositionFor(line: number, column: number): MappedPosition { + if (global['evalSources'] && global['evalSources'].find(s => this._generatedPath == s) && line > 0) line--; // check if eval code // source-map lib uses 1-indexed lines. line++; @@ -223,7 +224,7 @@ export class SourceMap { return null; } else { return { - line: position.line - 1, // Back to 0-indexed lines + line: global["evalSources"] && global["evalSources"].find(s => s == this._generatedPath) ? position.line : position.line - 1, // check if eval code else Back to 0-indexed lines column: position.column, source: this._generatedPath }; diff --git a/src/sourceMaps/sourceMapFactory.ts b/src/sourceMaps/sourceMapFactory.ts index de1928ab9..62ddfd2f7 100644 --- a/src/sourceMaps/sourceMapFactory.ts +++ b/src/sourceMaps/sourceMapFactory.ts @@ -93,13 +93,14 @@ function getSourceMapContent(pathToGenerated: string, mapPath: string): Promise< function loadSourceMapContents(mapPathOrURL: string): Promise { let contentsP: Promise; - if (utils.isURL(mapPathOrURL)) { + if (utils.isURL(mapPathOrURL) && !mapPathOrURL.startsWith('file://')) { logger.log(`SourceMaps.loadSourceMapContents: Downloading sourcemap file from ${mapPathOrURL}`); contentsP = downloadSourceMapContents(mapPathOrURL).catch(e => { logger.error(`SourceMaps.loadSourceMapContents: Could not download sourcemap from ${mapPathOrURL}`); return null; }); } else { + if (utils.isURL(mapPathOrURL)) mapPathOrURL = utils.canonicalizeUrl(mapPathOrURL); contentsP = new Promise((resolve, reject) => { logger.log(`SourceMaps.loadSourceMapContents: Reading local sourcemap file from ${mapPathOrURL}`); fs.readFile(mapPathOrURL, (err, data) => {