Skip to content

OffsetPosition lineContents wrongly includes a newline #56

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
inkytonik opened this issue Jul 2, 2015 · 2 comments
Closed

OffsetPosition lineContents wrongly includes a newline #56

inkytonik opened this issue Jul 2, 2015 · 2 comments
Labels

Comments

@inkytonik
Copy link

According to the documentation, the lineContents method of a Position should not include a newline, but this code:

def lineContents: String =
    source.subSequence(index(line - 1), index(line)).toString

includes everything from the start of line - 1 to the start of line thereby including the newline at the end of the line.

The effect of this bug is that messages that use Position.longString end up with an undesirable blank line between the contents line and the up arrow line since longString also puts a newline between the two:

LINE CONTENTS

      ^

Presumably the fix is to use index(line) - 1 in the above code instead of index(line) so that the newline is omitted.

@inkytonik
Copy link
Author

Actually that fix will only be valid if the source ends in a newline.

@gourlaysama
Copy link
Contributor

Fixed in #77.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants