Skip to content

Weird indentations if externally-formatted strings are used #46

@MoSal

Description

@MoSal
#[macro_use] extern crate prettytable;
extern crate ansi_term;

use prettytable::Table;
use ansi_term::Colour::Yellow;

fn main() {
    // Okay
    let mut table = Table::new();
    table.add_row(row![ Fybl->"AAAAAAA", Fmbl->"BBB", Fgbl->"CCC"]);
    table.add_row(row![ Fybl->"AAAAAAA", Fmbl->"BBB", Fgbl->"CCC"]);
    table.add_row(row![ Fybl->"AAAAAAA", Fmbl->"BBB", Fgbl->"CCC"]);
    table.add_row(row![ Fybl->"Yellow Yellow Yellow" ]);
    table.printstd();

    // Messed up
    let mut table2 = Table::new();
    table2.add_row(row![ Fybl->"AAAAAAA", Fmbl->"BBB", Fgbl->"CCC"]);
    table2.add_row(row![ Fybl->"AAAAAAA", Fmbl->"BBB", Fgbl->"CCC"]);
    table2.add_row(row![ Fybl->"AAAAAAA", Fmbl->"BBB", Fgbl->"CCC"]);
    table2.add_row(row![ Yellow.bold().paint("Yellow Yellow Yellow") ]);
    table2.printstd();
}

In table2, the first column in the first 3 rows has extra paddings. Those paddings exist regardless of the alignment requested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions