nomad / crop

🌾 A pretty fast text rope
https://crates.io/crates/crop
MIT License
261 stars 13 forks source link

Fix trailing_newline issue in Builder::build #17

Closed andyyu2004 closed 5 months ago

andyyu2004 commented 5 months ago

Hey! I found a little issue where building a rope using the builder would result in different line lengths compared to constructing the Rope directly (using Rope::from).

Buffer::has_trailing_newline transitively depends on len_left which depends on left_summary being up to date. However, Builder::finish was calling them in the reverse order so this wouldn't work in some cases.

Since has_trailing_newline is now false instead of true, the line length is too great by 1.

noib3 commented 5 months ago

Thank you!