-
Notifications
You must be signed in to change notification settings - Fork 119
add support to eval code and solve file:// url bug #220
Conversation
@Alphapage, It will cover your contributions to all Microsoft-managed open source projects. |
This PR could solve: |
For info, I use global to register evaled sources. This is ugly, but modules were not working. Maybe different process ! |
The main problems I was unable to solve:
|
@@ -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"] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use global
, try to find another way to share this list between modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried import/export without success. Do you have another idea ?
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to adjust the line differently based on whether it's an eval script or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think when code is an eval script, then (function(){\n
is added and chrome debugger result is offset by 1 line vs source-map which use the script code.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - the 0-indexed or 1-indexed lines are a property of the source-map lib, it doesn't matter whether the code originated as an eval script or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as previous answer. I think either generated and authored code relay on(function(){\n
problem.
in my opinion, it is more +1 indexed than 1-indexed: I keep the base index but add some adjustments.
Please see tslint issues as well |
I don't know how chrome debugger works, but the best way to solve this problem would be to send the eval file from //#sourceURL and sourcemap file from //#sourceMappingURL to chrome debugger and let chrome debugger do the job, apply breakpoints... |
No description provided.