Fix JS extractor line numbers being off on CRLF files#1288
Open
apoorva-01 wants to merge 1 commit into
Open
Conversation
The // and <!-- comment rules matched with .*, which eats the \r of a CRLF, so the comment kept a trailing \r counted as a newline (and the \n again). Restrict both to [^\r\n] so the pair counts once.
23bcec7 to
c1e2875
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #770.
The JS extractor reports different line numbers by line ending: a call after three comment lines shows on line 4 with LF but line 7 with CRLF.
It's the
//and<!--comment rules in jslexer. They match with.*, and.eats the\rof a CRLF, so the comment token keeps a trailing\rthat gets counted as a newline, then the\nis counted again, two lines per comment. Switching both to[^\r\n]*stops the comment before the newline so the\r\ncounts once. Added tests that LF and CRLF line numbers match.Left
CHANGES.rstalone since that's filled in at release, happy to add an entry.