1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Issue #3092: Fix column numbers in sourcemaps to not be essentially random.

This commit is contained in:
Jason Walton 2013-08-06 16:25:23 -04:00
parent 15517df417
commit 3ad332d5d4
2 changed files with 9 additions and 2 deletions

View file

@ -69,7 +69,11 @@
} }
newLines = helpers.count(fragment.code, "\n"); newLines = helpers.count(fragment.code, "\n");
currentLine += newLines; currentLine += newLines;
currentColumn = fragment.code.length - (newLines ? fragment.code.lastIndexOf("\n") : 0); if (newLines) {
currentColumn = fragment.code.length - (fragment.code.lastIndexOf("\n") + 1);
} else {
currentColumn += fragment.code.length;
}
} }
js += fragment.code; js += fragment.code;
} }

View file

@ -62,7 +62,10 @@ exports.compile = compile = withPrettyErrors (code, options) ->
{noReplace: true}) {noReplace: true})
newLines = helpers.count fragment.code, "\n" newLines = helpers.count fragment.code, "\n"
currentLine += newLines currentLine += newLines
currentColumn = fragment.code.length - (if newLines then fragment.code.lastIndexOf "\n" else 0) if newLines
currentColumn = fragment.code.length - (fragment.code.lastIndexOf("\n") + 1)
else
currentColumn += fragment.code.length
# Copy the code from each fragment into the final JavaScript. # Copy the code from each fragment into the final JavaScript.
js += fragment.code js += fragment.code