This repository was archived by the owner on Nov 25, 2021. It is now read-only.
Double-counts lines under certain (Windows) line-ending conditions #10
Open
Description
I discovered while traversing a produced AST that the node positions extended beyond the length of the file, nearly doubling the line length. After poking around and testing a hypothesis, I discovered that by normalizing lines endings to "\n", the line count returned to normal.
Operating System: Windows (works as expected on Mac)
Line ending: Windows standard (\r\n)
JSON source in question:
{
"Snippet snippet": {
"prefix": "snippet",
"body": [
"\"$1\": {",
"\t\"prefix\": \"$2\",",
"\t\"body\": [",
"\t\t$3",
"\t],",
"\t\"description\": \"$4\"",
"},"
],
"description": "A snippet for creating new snippets"
}
}
The normalization fix I applied in my parser abstraction is as follows:
function normalizeSourceLineEndings(source) {
return source.split(/\r?\n/).join('\n');
}
I know this project is old, and potentially unmaintained, but I figured this issue would, at least, help someone else if they encountered a similar issue.
Thank you for building this.
Cheers!
Metadata
Metadata
Assignees
Labels
No labels