Closed
Description
The method lineContents
of OffsetPosition
includes newlines contrary to the statement in the comment:
scala> val s = "foo\nbar"
s: String =
foo
bar
scala> val reader = new CharSequenceReader(s.toCharArray(), 0)
reader: scala.util.parsing.input.CharSequenceReader = scala.util.parsing.input.CharSequenceReader@4ad5e1aa
scala> val p = reader.pos.asInstanceOf[OffsetPosition]
p: scala.util.parsing.input.OffsetPosition = 1.1
scala> p.lineContents
res6: String =
"foo
"
This issue is fixed by adjusting the end index of lineContents
:
def lineContents: String =
source.subSequence(index(line - 1), index(line) - 1).toString