Skip to content
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

Fix Line Iterator creation for empty Rope #77

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

pascalkuthe
Copy link
Collaborator

Fixes #76.

In #70 I introduced a small oversight in the edge case of an empty Rope.
I initialized the Lines iterator with total_lines = 0.
However, the Lines iterator always yields atleast a single line (even if that line is empty)
which caused the subsequent underflow.
This PR fixes that by setting total_lines = 1 in the appropriate edge case.
I also added a test case to make sure this doesn't regress in the future.

@cessen
Copy link
Owner

cessen commented Jan 31, 2023

Looks good to me! Thanks!

@cessen cessen merged commit e1e59b8 into cessen:master Jan 31, 2023
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.

subtract with overflow in new line iterator
2 participants