Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Table cells currently wrap at character boundaries, splitting words mid-stream (e.g., "all-in-one-wp-migration-multisite-extension" becomes "mult" / "isite-extension"), making long values difficult to copy/paste.

Changes

Added three wrapping modes:

  • wrap - Character-boundary wrapping (default, preserves existing behavior)
  • word-wrap - Wraps at spaces and hyphens, keeping words intact
  • truncate - Single-line display with ellipsis

Implementation:

  • Added setWrappingMode() to Table and Ascii classes
  • Refactored wrapping logic into wrapText() and wordWrap() helpers
  • Added validation for mode values

Usage

$table = new \cli\Table();
$table->setHeaders(['name', 'version', 'status']);
$table->setRows($data);
$table->setWrappingMode('word-wrap');  // or 'truncate'
$table->display();

Comparison

Before (character-boundary):

| all-in-one-wp-migration-mult | 4.34 | inactive |
| isite-extension              |      |          |

With word-wrap:

| all-in-one-wp-migration-     | 4.34 | inactive |
| multisite-extension          |      |          |

With truncate:

| all-in-one-wp-migration-m... | 4.34 | inactive |
Original prompt

This section details on the original issue you should resolve

<issue_title>Wordwrapping in the tabular output</issue_title>
<issue_description>Hi there,

This is either a feature request or a support request, depending on whether the functionality I'm seeking exists.

In my terminal, whose usual dimensions are the standard 80x24, when I list things like plugins, I get output like that below:

$ wp plugin list --fields=name,version,update_version,status

+-----------------------+--------------------------+----------------+----------+
| name                  | version                  | update_version | status   |
+-----------------------+--------------------------+----------------+----------+
| advanced-custom-field | 6.2.7                    |                | active   |
| s                     |                          |                |          |
| advanced-query-loop   | 2.1.1                    |                | active   |
| all-in-one-wp-migrati | 7.81                     |                | inactive |
| on                    |                          |                |          |
| all-in-one-wp-migrati | 4.34                     |                | inactive |
| on-multisite-extensio |                          |                |          |
| n                     |                          |                |          |
+-----------------------+--------------------------+----------------+----------+

As you can see, the plugin names wrap onto multiple lines. I sometimes wish to copy and paste the names, but the line wrapping interferes with this. I know I can 1) widen my terminal and re-run the command or 2) pipe the output to a file (which strips the columnar formatting), but I'm wondering if there is a way to either...

  • display the content like the mysql client does, wrapping over lines but never in columns when the width of the content exceeds the terminal width.
  • or explicitly set the width of a given column or columns (even if that truncates some content).

I think "mysql client behavior" might be useful for more than just me.

Thanks for sharing your thoughts.

Saul</issue_description>

Comments on the Issue (you are @copilot in this section)

@swissspidy Related:

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add setWrappingMode() method to Ascii renderer and Table class
- Support three modes: 'wrap' (default), 'word-wrap', and 'truncate'
- word-wrap mode wraps at word boundaries (spaces/hyphens)
- truncate mode truncates with ellipsis (...)
- Add helper methods wrapText() and wordWrap() for wrapping logic
- Add tests for new functionality

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 80.32787% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/cli/table/Ascii.php 79.31% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

- Add comprehensive examples for all three wrapping modes
- Include explanations of when to use each mode
- Add usage instructions in the example output
- Make executable with proper shebang

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix wordwrapping in the tabular output Add configurable wrapping modes for table columns Feb 2, 2026
Copilot AI requested a review from swissspidy February 2, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wordwrapping in the tabular output

2 participants