-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support '\r' and '\r\n' line endings, closes scala/bug#5669 #164
Conversation
if (source.charAt(i) == '\n') lineStarts += (i + 1) | ||
lineStarts += source.length | ||
lineStarts += 0 // first line | ||
for (i <- 0 until source.length) { |
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.
may as well use for i <- 1 until source.length
and remove the if i>= 1
checks below
lineStarts += source.length | ||
lineStarts += 0 // first line | ||
for (i <- 0 until source.length) { | ||
if (i >= 1 && source.charAt(i - 1) == '\n') // \n or \r\n |
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.
the majority of the time the last character won't be a \r
or \n
might be worth binding charAt(i - 1)
to a variable to save the extra lookup (dependant on the performance requirements of this code)
in the Scala community build, this build caused this Twirl test case to start failing: https://github.com/playframework/twirl/blob/68ad7b378be54887a09c5a67792bacc933d17d68/parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala#L187-L189 (referencing https://github.com/playframework/twirl/blob/master/parser/src/test/resources/unclosedBracket2.scala.html)
the test file doesn't have any |
I've reproduced it: |
No description provided.