mgeisler / textwrap

An efficient and powerful Rust library for word wrapping text.
MIT License
446 stars 44 forks source link

`display_width`: ignore ANSI hyperlinks in width calculation #526

Closed tertsdiepraam closed 7 months ago

tertsdiepraam commented 10 months ago

Closes https://github.com/mgeisler/textwrap/issues/525

I've attempted to keep the implementation similar to the current implementation and added a simple test for it. This keeps it in a bit of an awkward state (e.g. comparing with CSI.1 in one branch and ']' in the other). Happy to take suggestions for the direction to take this PR!

anthraxx commented 7 months ago

I was actually hit by this bug and found this PR. @mgeisler any chance you can take a look :cat:

tertsdiepraam commented 7 months ago

I added support for a BEL character as separator between the link and the text. This is used by some programs such as GNU ls and therefore also uutils ls. Since this PR has not seen any activity, I'll be moving uutils to my own crate, but I figured I would still fix the same issue here. I think it would still be nice for the community to have this PR merged!

mgeisler commented 7 months ago

Thanks for the ping! I'm sorry I had forgotten about this... let's merge it right away so I can make a new release.

tertsdiepraam commented 7 months ago

Thanks!

mgeisler commented 6 months ago

I finally got around to merge the release PR: #533 and this means 0.16.1 is available!