Allow wrap to borrow when preserve_trailing_space is true#593
Allow wrap to borrow when preserve_trailing_space is true#593mgeisler merged 6 commits intomgeisler:masterfrom
preserve_trailing_space is true#593Conversation
Currently, if preserve_trailing_space is true, then wrap always copies. This seems like a bug. This commit allows it to borrow instead of copy.
|
The correctness of this pull request relies on the invariant that |
|
Apologies, I made a silly mistake. I didn't realize that additional commits on my fork would be automatically included in this pull request. The extra two commits making wrap_single_line public were not intended to be included. |
Yes, you are correct! The logic in I kind of consider I don't know if anyone has ever done this, but it was the idea behind the design here. The name
Thanks for noticing and fixing that! I looked at the change now, sorry about the wait! Would you be able to add a new unit test which demonstrates that we are now borrowing more than we use to do? It's frankly a bit subtle, so I would love to have a test to confirm what is going on. |
|
Thanks for the reply! Just added a unit test which failed before the change. I'll restate what I changed a little more clearly, because I agree it's subtle. Previously, After my change, |
Thank you for this, now I see why this is a big deal! Cc @HidenoriKobayashi as well, who wrote the code for this in #587. |
preserve_trailing_space is true
This pull request modifies
wrap_single_line_slow_pathto borrow when preserve_trailing_space is set and the final word has no penalty. Previously, it was unnecessarily forcing a copy in this case. I believe that logic remains exactly the same in all other cases.