Check for newline when reading or updating source. #5

wants to merge 1 commit into


None yet

2 participants

If you parse code without newline characters, i.e.

"var a =1;if ( a==1){ a=2; }"

the node range values are correct, but the source() and update() functions assume a newline character follows (node.range[1] + 1).

Instead of automatically adding 1, I added an internal function to check for the newline character and if it exists add 1, otherwise add 0.


This fix breaks a lot of tests.

I'll take a look and push corrections

Sorry, I think the problem is coming from esprima.
When I parse a line like:
var a=3;if(a==1){a=2;}else if(a==3){a=4;}
it has the wrong node.range values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment