Skip to content

Fix a bug where the reader was double counting the CRLF newline seq #1064

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

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

ikappaki
Copy link
Contributor

@ikappaki ikappaki commented Sep 19, 2024

Hi,

can you please a fix for the line number in the metadata generated by the reader. It fixes #1063.

We now check the char at -2 only if it’s:

  • \n (for \nC or \r\nC case)
  • \r (for the \rC, but not \r\n, case).

where C is any other char.

Added tests for the same.

Thanks

@pytest.mark.parametrize(
"evalstr,first,second",
[
("[5]\n(def n 123)", (1, 1, 0, 3), (2, 2, 0, 11)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add cases for buffers starting with \n and \r\n as well since we're looking back in the last 2 characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the following, is this what you had in mind?

            ("\n[5]\n(def n 123)", (2, 2, 0, 3), (3, 3, 0, 11)),
            ("\r[5]\r(def n 123)", (2, 2, 0, 3), (3, 3, 0, 11)),
            ("\r\n[5]\r\n(def n 123)", (2, 2, 0, 3), (3, 3, 0, 11)),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Thanks!

@chrisrink10 chrisrink10 merged commit dd7d239 into basilisp-lang:main Sep 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double counting of CRLF newline seq in metadata
2 participants