Skip to content

Commit 7fe2897

Browse files
committed
Start for loop from 1
1 parent 77ffd91 commit 7fe2897

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

shared/src/main/scala/scala/util/parsing/input/OffsetPosition.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ case class OffsetPosition(source: CharSequence, offset: Int) extends Position {
3535
private def genIndex: Array[Int] = {
3636
val lineStarts = new ArrayBuffer[Int]
3737
lineStarts += 0 // first line
38-
for (i <- 0 until source.length) {
39-
if (i >= 1 && source.charAt(i - 1) == '\n') // \n or \r\n
38+
for (i <- 1 until source.length) {
39+
if (source.charAt(i - 1) == '\n') // \n or \r\n
4040
lineStarts += i
41-
else if (i >= 1 && source.charAt(i - 1) == '\r' && source.charAt(i) != '\n') // \r but not \r\n
41+
else if (source.charAt(i - 1) == '\r' && source.charAt(i) != '\n') // \r but not \r\n
4242
lineStarts += i
4343
}
4444
lineStarts += source.length // eof

0 commit comments

Comments
 (0)