-
Notifications
You must be signed in to change notification settings - Fork 229
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 truncate of table cells containing ANSI #256
Conversation
@charmbracelet Can I get a review for this very small bug fix. Thanks. |
@maaslalani Would you be able to do a review of this fix? Thanks. |
Hey @mikelorant, this looks great! Do you mind adding a test for ANSI truncation so this doesn't regress again? |
Take a look at the tests file and you'lll see why this is going to be a really big problem. Options:
|
I would go with the 3rd option to test strings that have |
Table cells (including the header) may contain ANSI codes. When determining the width of these cells, ANSI was not excluded. The `reflow` package has the same truncate function that is aware of ANSI. This improves cell width calculation and correctly truncates. Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
14d73ee
to
b81c89f
Compare
Had a little fun with the test by making the header an incredibly long ANSI string. Have confirmed this test fails on the master branch without the fix.
With the fix, test passes:
|
Nice work on this one @mikelorant, thank you so much! |
Table cells (including the header) may contain ANSI codes. When determining the width of these cells, ANSI was not excluded.
The
reflow
package has the same truncate function that is aware of ANSI. This improves cell width calculation and correctly truncates.