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.
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.
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.