Skip to content

OffsetPosition lineContents includes newline #7483

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

Closed
scabug opened this issue May 15, 2013 · 2 comments
Closed

OffsetPosition lineContents includes newline #7483

scabug opened this issue May 15, 2013 · 2 comments

Comments

@scabug
Copy link

scabug commented May 15, 2013

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
@scabug
Copy link
Author

scabug commented May 15, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7483?orig=1
Reporter: Lukas B (r0estir0bbe)

@scabug
Copy link
Author

scabug commented Jul 17, 2015

@SethTisue said:
The parser combinators library is now community-maintained. Issues with it are now tracked at scala/scala-parser-combinators#61 instead of here in the Scala JIRA.

Interested community members: if you consider this issue significant, feel free to open a new issue for it on GitHub, with links in both directions.

@scabug scabug closed this as completed Jul 17, 2015
Philippus added a commit to Philippus/scala-parser-combinators that referenced this issue Jun 27, 2018
SethTisue added a commit to scala/scala-parser-combinators that referenced this issue Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant