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 is_grapheme_boundary panic on empty rope #24

Merged
merged 3 commits into from
Mar 13, 2025
Merged

Conversation

evanrelf
Copy link
Contributor

unwrap() at src/rope/utils.rs:172:

let chunk = chunks.next_back().unwrap();

If the rope is empty, the chunks iterator won't yield any items. We can avoid hitting this case, and do less work, if we recognize that an empty rope has one valid grapheme boundary, at byte offset 0.

evanrelf and others added 2 commits March 12, 2025 21:53
`unwrap()` at `src/rope/utils.rs:172`:

https://github.com/nomad/crop/blob/ae8ac1669e1024df42b18ec3e26c3f8d933cebc2/src/rope/utils.rs#L172

If the rope is empty, the `chunks` iterator won't yield any items. We
can avoid hitting this case, and do less work, if we recognize that an
empty rope has one valid grapheme boundary, at byte offset 0.
noib3

This comment was marked as off-topic.

@evanrelf evanrelf requested a review from noib3 March 13, 2025 16:23
@noib3 noib3 merged commit af51af2 into nomad:main Mar 13, 2025
8 checks passed
@noib3
Copy link
Collaborator

noib3 commented Mar 13, 2025

Thanks!

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.

2 participants