prettytable-rs icon indicating copy to clipboard operation
prettytable-rs copied to clipboard

Cell width incorrect when using external formatting

Open Myzel394 opened this issue 1 year ago • 5 comments

This has already been discussed in #46 and it seemed as if this got resolved. However, it seems as if this is still an issue / reoccurred.

Here's an example when using the colored crate:

use colored::Colorize;
use prettytable::{format, row, Table};

fn main() {
        let mut table = Table::new();

        table.add_row(row![
            "Hello".yellow(),
        ]);

        table.printstd();
}

running this results in the following table:

+---------+
| Hello |
+---------+

you can see at the end the cell is one character too small

Myzel394 avatar Jun 08 '24 18:06 Myzel394

Probably this:

  • https://github.com/phsym/prettytable-rs/blob/master/src/utils.rs#L86

Needs re-work - wanna do and send a patch that contains proper testing of it ?

pinkforest avatar Jun 08 '24 18:06 pinkforest

I've got into the same issue after cargo update that changed unicode-width dependency version from v0.1.11 -> v0.1.13.

Adding unicode-width = "=0.1.12" to Cargo.toml workarounds the problem, so it looks like the current logic is not compatible with the following changes – https://github.com/unicode-rs/unicode-width/compare/v0.1.12...v0.1.13

KonishchevDmitry avatar Aug 16 '24 05:08 KonishchevDmitry

Pinning dependencies asks for trouble e.g. duplication etc. It needs to be addressed here as compat issue if so.

Someone just has to work on it and submit a patch.

pinkforest avatar Aug 16 '24 06:08 pinkforest

@pinkforest, please take a look at https://github.com/phsym/prettytable-rs/pull/170.

KonishchevDmitry avatar Nov 04 '24 12:11 KonishchevDmitry

@pinkforest, last ping: could you please merge the PR and bump version?

KonishchevDmitry avatar Jan 11 '25 10:01 KonishchevDmitry