Skip to content

[Console] Table width does not take paddings into account / lacks cell wrapping #22156

Closed
@ro0NL

Description

@ro0NL
Q A
Bug report? no
Feature request? yes
Symfony version master

Given

dump('benchmark');
$output->writeln(str_repeat('-', getenv('COLUMNS')));

dump('table short; min width');
$table = new Table($output);
$table->setRows(array(
    array(implode(', ', range('A', 'Z'))),
));
$table->setColumnWidths(array(getenv('COLUMNS')));
$table->render();

dump('table long; default width');
$table = new Table($output);
$table->setRows(array(
    array(implode(', ', range('1', '100'))),
));
$table->render();

It renders

image

For the min-width example i expected a perfectly fitting table :)

The default-width example works as documented, and setColumnWidth wont help, because that's actually setMinColumnWidth (also documented i believe :))

Imo. we're missing a setMaxColumnWidth or something to control text wrapping. Im not sure we should ever exceed the max. (terminal) width unless we cant wrap any further of course.

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions