Skip to content
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

Cell width incorrect when using external formatting #165

Open
Myzel394 opened this issue Jun 8, 2024 · 4 comments · May be fixed by #170
Open

Cell width incorrect when using external formatting #165

Myzel394 opened this issue Jun 8, 2024 · 4 comments · May be fixed by #170

Comments

@Myzel394
Copy link

Myzel394 commented Jun 8, 2024

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

@pinkforest
Copy link
Collaborator

Probably this:

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

KonishchevDmitry added a commit to KonishchevDmitry/investments that referenced this issue Aug 16, 2024
@KonishchevDmitry
Copy link

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 – unicode-rs/unicode-width@v0.1.12...v0.1.13

@pinkforest
Copy link
Collaborator

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.

facebook-github-bot pushed a commit to facebook/sapling that referenced this issue Oct 25, 2024
… in prettytable-rs when using cell containing string formatted with Colored crate.

Summary:
I have noticed that recently `metalctl` CLI started rendering table with wrong cells widths:

{F1946659102}

After looking around I found this [Issue](phsym/prettytable-rs#165) reported exactly the same problem.

In `metalos` we **do** use Colored crate:

https://www.internalfb.com/code/fbsource/[769b00238690]/fbcode/metalos/metald/if/rust/src/api.rs?lines=206-220

And this messes up with the width.
An user in that GH issue reported pinning unicode-width to 0.1.12 works around the problem hence this is what I am doing this.

This started happening after `unicode-width` got bumped in tp2 from `0.1.12` to `0.1.14` on the 21st of October: https://www.internalfb.com/phabricator/commit/FBS/7c9387478e0a3a1d1876ec4a5a17599510994711

I am aware pinning dependencies asks for trouble e.g. duplication etc.
We can remove the pin after this issue is fixed in `prettytable-rs` and I added a comment about that in Cargo.toml

Differential Revision: D64960800

fbshipit-source-id: 7fa29b15b1cae7d5a0f75a44f0d4f221e78c7a91
facebook-github-bot pushed a commit to facebook/hhvm that referenced this issue Oct 25, 2024
… in prettytable-rs when using cell containing string formatted with Colored crate.

Summary:
I have noticed that recently `metalctl` CLI started rendering table with wrong cells widths:

{F1946659102}

After looking around I found this [Issue](phsym/prettytable-rs#165) reported exactly the same problem.

In `metalos` we **do** use Colored crate:

https://www.internalfb.com/code/fbsource/[769b00238690]/fbcode/metalos/metald/if/rust/src/api.rs?lines=206-220

And this messes up with the width.
An user in that GH issue reported pinning unicode-width to 0.1.12 works around the problem hence this is what I am doing this.

This started happening after `unicode-width` got bumped in tp2 from `0.1.12` to `0.1.14` on the 21st of October: https://www.internalfb.com/phabricator/commit/FBS/7c9387478e0a3a1d1876ec4a5a17599510994711

I am aware pinning dependencies asks for trouble e.g. duplication etc.
We can remove the pin after this issue is fixed in `prettytable-rs` and I added a comment about that in Cargo.toml

Differential Revision: D64960800

fbshipit-source-id: 7fa29b15b1cae7d5a0f75a44f0d4f221e78c7a91
KonishchevDmitry added a commit to KonishchevDmitry/prettytable-rs that referenced this issue Nov 4, 2024
KonishchevDmitry added a commit to KonishchevDmitry/prettytable-rs that referenced this issue Nov 4, 2024
KonishchevDmitry added a commit to KonishchevDmitry/prettytable-rs that referenced this issue Nov 4, 2024
KonishchevDmitry added a commit to KonishchevDmitry/prettytable-rs that referenced this issue Nov 4, 2024
@KonishchevDmitry
Copy link

@pinkforest, please take a look at #170.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants